mirror of
https://github.com/flarum/framework.git
synced 2024-12-13 07:03:35 +08:00
CSRF protection on logout action
This commit is contained in:
parent
23eec806e6
commit
c6e297e849
|
@ -1,5 +1,6 @@
|
|||
<?php namespace Flarum\Forum\Actions;
|
||||
|
||||
use Flarum\Api\AccessToken;
|
||||
use Flarum\Forum\Events\UserLoggedOut;
|
||||
use Flarum\Support\Action;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
@ -18,6 +19,10 @@ class LogoutAction extends Action
|
|||
$user = app('flarum.actor');
|
||||
|
||||
if ($user->exists) {
|
||||
$token = array_get($request->getQueryParams(), 'token');
|
||||
|
||||
AccessToken::where('user_id', $user->id)->findOrFail($token);
|
||||
|
||||
$user->accessTokens()->delete();
|
||||
|
||||
event(new UserLoggedOut($user));
|
||||
|
|
Loading…
Reference in New Issue
Block a user