mirror of
https://github.com/flarum/framework.git
synced 2024-11-27 11:03:37 +08:00
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.
This commit is contained in:
parent
bdac88b573
commit
c6c1ae32e6
|
@ -14,13 +14,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
|
||||
|
@ -58,15 +56,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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user