mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-06 17:41:01 +00:00
Protect revoke_token with a CSRF token
This commit is contained in:
parent
d703fa6a3a
commit
ac5b5fb379
3 changed files with 33 additions and 14 deletions
|
@ -455,22 +455,22 @@ class ConfigController extends AbstractController
|
|||
}
|
||||
|
||||
/**
|
||||
* @Route("/revoke-token", name="revoke_token")
|
||||
* @Route("/revoke-token", name="revoke_token", methods={"POST"})
|
||||
*
|
||||
* @return RedirectResponse|JsonResponse
|
||||
*/
|
||||
public function revokeTokenAction(Request $request)
|
||||
{
|
||||
if (!$this->isCsrfTokenValid('revoke-token', $request->request->get('token'))) {
|
||||
throw new BadRequestHttpException('Bad CSRF token.');
|
||||
}
|
||||
|
||||
$config = $this->getConfig();
|
||||
$config->setFeedToken(null);
|
||||
|
||||
$this->entityManager->persist($config);
|
||||
$this->entityManager->flush();
|
||||
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
return new JsonResponse();
|
||||
}
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
'flashes.config.notice.feed_token_revoked'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue