Skip to content

Commit

Permalink
check if token is valid, added translations
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Jul 14, 2022
1 parent c8975ad commit 5a00ff4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [1.23.5] - 2022-07-14
- Changed: added some translations to token check
- Fixed: missing token validation check

## [1.23.4] - 2022-06-30
- Fixed: issue on sending messages with notification center queue

Expand Down
8 changes: 7 additions & 1 deletion classes/EventListener/GeneratePageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function __invoke(PageModel $pageModel, LayoutModel $layout, PageRegular
$this->errorRedirect('Token already confirmed!', $form);
}

if (!$token->isValid()) {
$this->errorRedirect('Token is expired or no longer valid.', $form);
}

// Valid token, do confirm process

$token->confirm();
Expand Down Expand Up @@ -136,6 +140,8 @@ private function errorRedirect(string $errorCode, FormModel $form = null): void
}

Input::setGet('token', null);
throw new PageNotFoundException('Invalid token! (Error: '.$errorCode.')');
throw new PageNotFoundException(
($GLOBALS['TL_LANG']['ERR']['submission']['invalidToken'] ?? 'Invalid token!').' (Error: '.$errorCode.')'
);
}
}
3 changes: 3 additions & 0 deletions languages/de/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
$GLOBALS['TL_LANG']['MSC']['salutation']['male'] = 'Herr';
$GLOBALS['TL_LANG']['MSC']['salutation']['female'] = 'Frau';
$GLOBALS['TL_LANG']['MSC']['salutation']['divers'] = 'Divers';


$GLOBALS['TL_LANG']['ERR']['submission']['invalidToken'] = 'Ungültiger Bestätigungslink!';
2 changes: 2 additions & 0 deletions languages/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
$GLOBALS['TL_LANG']['MSC']['salutation']['male'] = 'Mr.';
$GLOBALS['TL_LANG']['MSC']['salutation']['female'] = 'Mrs.';
$GLOBALS['TL_LANG']['MSC']['salutation']['divers'] = 'Divers';

$GLOBALS['TL_LANG']['ERR']['submission']['invalidToken'] = 'Invalid confirmation link!';

0 comments on commit 5a00ff4

Please sign in to comment.