aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ConfigController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 5bbe1c74..846e96ff 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -81,23 +81,23 @@ class ConfigController extends Controller
81 $userForm->handleRequest($request); 81 $userForm->handleRequest($request);
82 82
83 // `googleTwoFactor` isn't a field within the User entity, we need to define it's value in a different way 83 // `googleTwoFactor` isn't a field within the User entity, we need to define it's value in a different way
84 if (true === $user->isGoogleAuthenticatorEnabled() && false === $userForm->isSubmitted()) { 84 if ($this->getParameter('twofactor_auth') && true === $user->isGoogleAuthenticatorEnabled() && false === $userForm->isSubmitted()) {
85 $userForm->get('googleTwoFactor')->setData(true); 85 $userForm->get('googleTwoFactor')->setData(true);
86 } 86 }
87 87
88 if ($userForm->isSubmitted() && $userForm->isValid()) { 88 if ($userForm->isSubmitted() && $userForm->isValid()) {
89 // handle creation / reset of the OTP secret if checkbox changed from the previous state 89 // handle creation / reset of the OTP secret if checkbox changed from the previous state
90 if (true === $userForm->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) { 90 if ($this->getParameter('twofactor_auth')) {
91 $secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret(); 91 if (true === $userForm->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) {
92 $secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret();
92 93
93 $user->setGoogleAuthenticatorSecret($secret); 94 $user->setGoogleAuthenticatorSecret($secret);
94 $user->setEmailTwoFactor(false); 95 $user->setEmailTwoFactor(false);
95 96
96 $qrCode = $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user); 97 $this->addFlash('OtpQrCode', $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user));
97 98 } elseif (false === $userForm->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) {
98 $this->addFlash('OTPSecret', ['code' => $secret, 'qrCode' => $qrCode]); 99 $user->setGoogleAuthenticatorSecret(null);
99 } elseif (false === $userForm->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) { 100 }
100 $user->setGoogleAuthenticatorSecret(null);
101 } 101 }
102 102
103 $userManager->updateUser($user, true); 103 $userManager->updateUser($user, true);