diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-12-02 18:39:02 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-01-23 13:28:02 +0100 |
commit | 2dfbe9e5faf40364b60e6c76f3cc9fac5bf11fa4 (patch) | |
tree | 463e9a7a036f736a1fbb676f4fddf113f8a8cb72 /src/Wallabag/CoreBundle/Controller/ConfigController.php | |
parent | edc79ad886e4c96d1c2d205fedf5a9c19a177ee1 (diff) | |
download | wallabag-2dfbe9e5faf40364b60e6c76f3cc9fac5bf11fa4.tar.gz wallabag-2dfbe9e5faf40364b60e6c76f3cc9fac5bf11fa4.tar.zst wallabag-2dfbe9e5faf40364b60e6c76f3cc9fac5bf11fa4.zip |
Fix tests
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 20 |
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); |