From 5d768db6d253c0505220e63370383c753a49160e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 14 Aug 2019 19:45:54 +0200 Subject: [PATCH] Bubble up exception for invalid confirmation token This way, the error handler can simply be amended to deal with this exception type with a dedicated error message or page. Refs #1337. Closes #1528. --- src/Forum/Controller/ConfirmEmailController.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Forum/Controller/ConfirmEmailController.php b/src/Forum/Controller/ConfirmEmailController.php index 1470f2846..24e303d3a 100644 --- a/src/Forum/Controller/ConfirmEmailController.php +++ b/src/Forum/Controller/ConfirmEmailController.php @@ -12,13 +12,11 @@ namespace Flarum\Forum\Controller; use Flarum\Foundation\Application; use Flarum\Http\SessionAuthenticator; use Flarum\User\Command\ConfirmEmail; -use Flarum\User\Exception\InvalidConfirmationTokenException; use Illuminate\Contracts\Bus\Dispatcher; use Illuminate\Support\Arr; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Server\RequestHandlerInterface; -use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\RedirectResponse; class ConfirmEmailController implements RequestHandlerInterface @@ -56,15 +54,11 @@ class ConfirmEmailController implements RequestHandlerInterface */ public function handle(Request $request): ResponseInterface { - try { - $token = Arr::get($request->getQueryParams(), 'token'); + $token = Arr::get($request->getQueryParams(), 'token'); - $user = $this->bus->dispatch( - new ConfirmEmail($token) - ); - } catch (InvalidConfirmationTokenException $e) { - return new HtmlResponse('Invalid confirmation token'); - } + $user = $this->bus->dispatch( + new ConfirmEmail($token) + ); $session = $request->getAttribute('session'); $this->authenticator->logIn($session, $user->id);