|
14 | 14 | use OCA\Forms\Db\SubmissionMapper; |
15 | 15 | use OCA\Forms\Service\ConfigService; |
16 | 16 | use OCA\Forms\Service\FormsService; |
| 17 | +use OCA\Forms\Service\SubmissionVerificationService; |
17 | 18 |
|
18 | 19 | use OCP\Accounts\IAccountManager; |
19 | 20 | use OCP\AppFramework\Controller; |
@@ -49,6 +50,7 @@ public function __construct( |
49 | 50 | private SubmissionMapper $submissionMapper, |
50 | 51 | private ConfigService $configService, |
51 | 52 | private FormsService $formsService, |
| 53 | + private SubmissionVerificationService $submissionVerificationService, |
52 | 54 | private IAccountManager $accountManager, |
53 | 55 | private IInitialState $initialState, |
54 | 56 | private IL10N $l10n, |
@@ -118,6 +120,27 @@ public function submitViewWithSubmission(string $hash, int $submissionId): Templ |
118 | 120 | return $this->formMapper->findByHash($hash)->getAllowEditSubmissions() ? $this->index($hash, $submissionId) : $this->index($hash); |
119 | 121 | } |
120 | 122 |
|
| 123 | + #[NoAdminRequired()] |
| 124 | + #[NoCSRFRequired()] |
| 125 | + #[PublicPage()] |
| 126 | + #[FrontpageRoute(verb: 'GET', url: '/verify/{token}', requirements: ['token' => '[a-f0-9]{48}'])] |
| 127 | + public function verifySubmissionEmail(string $token): PublicTemplateResponse { |
| 128 | + $isVerified = $this->submissionVerificationService->verifyToken($token); |
| 129 | + |
| 130 | + $response = new PublicTemplateResponse($this->appName, 'verify', [ |
| 131 | + 'verified' => $isVerified, |
| 132 | + 'headline' => $isVerified |
| 133 | + ? $this->l10n->t('Email address verified') |
| 134 | + : $this->l10n->t('Email verification failed'), |
| 135 | + 'message' => $isVerified |
| 136 | + ? $this->l10n->t('Your email address has been verified successfully. You can close this page now.') |
| 137 | + : $this->l10n->t('The verification link is invalid or expired.'), |
| 138 | + ]); |
| 139 | + $response->setHeaderTitle($this->l10n->t('Forms')); |
| 140 | + |
| 141 | + return $response; |
| 142 | + } |
| 143 | + |
121 | 144 | /** |
122 | 145 | * @param string $hash |
123 | 146 | * @return RedirectResponse|TemplateResponse Redirect to login or internal view. |
|
0 commit comments