diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9eee7c86f..ae5029a61 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -57,5 +57,5 @@ parameters: - message: "#^Method FOS\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:updateUser()#" - count: 6 + count: 7 path: src/Wallabag/CoreBundle/Controller/ConfigController.php diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 1ba7faaed..cca2cf962 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -402,12 +402,14 @@ class ConfigController extends AbstractController throw new BadRequestHttpException('Bad CSRF token.'); } + $user = $this->getUser(); + $isValid = $googleAuthenticator->checkCode( - $this->getUser(), + $user, $request->get('_auth_code') ); - if (true === $isValid) { + if ($isValid) { $this->addFlash( 'notice', 'flashes.config.notice.otp_enabled' @@ -417,14 +419,14 @@ class ConfigController extends AbstractController } $this->addFlash( - 'two_factor', - 'scheb_two_factor.code_invalid' + 'notice', + 'flashes.config.notice.otp_code_invalid' ); - $this->addFlash( - 'notice', - 'scheb_two_factor.code_invalid' - ); + $user->setGoogleAuthenticatorSecret(null); + $user->setBackupCodes(null); + + $this->userManager->updateUser($user, true); return $this->redirect($this->generateUrl('config') . '#set3'); } diff --git a/src/Wallabag/CoreBundle/Resources/views/Config/otp_app.html.twig b/src/Wallabag/CoreBundle/Resources/views/Config/otp_app.html.twig index 6d5d402b1..529b7cf04 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Config/otp_app.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Config/otp_app.html.twig @@ -45,7 +45,7 @@