X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FConfigController.php;fp=src%2FWallabag%2FCoreBundle%2FController%2FConfigController.php;h=56efe82bb88775a8f3e5fac4134a53bec85e72b8;hb=4ff1efa41883f80bb1764ea97dd9dd46b557a979;hp=6655ef93da56781438fb769cd437adbf2e349ae0;hpb=365b3dd21f7c4f3e7f2b6f1502f284a6190dd918;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 6655ef93..56efe82b 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -192,6 +192,30 @@ class ConfigController extends Controller ]); } + /** + * Disable 2FA using email. + * + * @Route("/config/otp/email/disable", name="disable_otp_email") + */ + public function disableOtpEmailAction() + { + if (!$this->getParameter('twofactor_auth')) { + return $this->createNotFoundException('two_factor not enabled'); + } + + $user = $this->getUser(); + $user->setEmailTwoFactor(false); + + $this->container->get('fos_user.user_manager')->updateUser($user, true); + + $this->addFlash( + 'notice', + 'flashes.config.notice.otp_disabled' + ); + + return $this->redirect($this->generateUrl('config') . '#set3'); + } + /** * Enable 2FA using email. * @@ -219,6 +243,32 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config') . '#set3'); } + /** + * Disable 2FA using OTP app. + * + * @Route("/config/otp/app/disable", name="disable_otp_app") + */ + public function disableOtpAppAction() + { + if (!$this->getParameter('twofactor_auth')) { + return $this->createNotFoundException('two_factor not enabled'); + } + + $user = $this->getUser(); + + $user->setGoogleAuthenticatorSecret(''); + $user->setBackupCodes(null); + + $this->container->get('fos_user.user_manager')->updateUser($user, true); + + $this->addFlash( + 'notice', + 'flashes.config.notice.otp_disabled' + ); + + return $this->redirect($this->generateUrl('config') . '#set3'); + } + /** * Enable 2FA using OTP app, user will need to confirm the generated code from the app. * @@ -248,6 +298,11 @@ class ConfigController extends Controller $this->container->get('fos_user.user_manager')->updateUser($user, true); + $this->addFlash( + 'notice', + 'flashes.config.notice.otp_enabled' + ); + return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [ 'backupCodes' => $backupCodes, 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user),