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.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index ed92c999..9257ab18 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -197,18 +197,25 @@ class ConfigController extends Controller
197 } 197 }
198 198
199 $user = $this->getUser(); 199 $user = $this->getUser();
200 $secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret();
200 201
201 if (!$user->isGoogleTwoFactor()) { 202 $user->setGoogleAuthenticatorSecret($secret);
202 $secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret(); 203 $user->setEmailTwoFactor(false);
203 204
204 $user->setGoogleAuthenticatorSecret($secret); 205 $backupCodes = (new BackupCodes())->toArray();
205 $user->setEmailTwoFactor(false); 206 $backupCodesHashed = array_map(
206 $user->setBackupCodes((new BackupCodes())->toArray()); 207 function ($backupCode) {
208 return password_hash($backupCode, PASSWORD_DEFAULT);
209 },
210 $backupCodes
211 );
207 212
208 $this->container->get('fos_user.user_manager')->updateUser($user, true); 213 $user->setBackupCodes($backupCodesHashed);
209 } 214
215 $this->container->get('fos_user.user_manager')->updateUser($user, true);
210 216
211 return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [ 217 return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [
218 'backupCodes' => $backupCodes,
212 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user), 219 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user),
213 ]); 220 ]);
214 } 221 }