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.php55
1 files changed, 55 insertions, 0 deletions
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
@@ -193,6 +193,30 @@ class ConfigController extends Controller
193 } 193 }
194 194
195 /** 195 /**
196 * Disable 2FA using email.
197 *
198 * @Route("/config/otp/email/disable", name="disable_otp_email")
199 */
200 public function disableOtpEmailAction()
201 {
202 if (!$this->getParameter('twofactor_auth')) {
203 return $this->createNotFoundException('two_factor not enabled');
204 }
205
206 $user = $this->getUser();
207 $user->setEmailTwoFactor(false);
208
209 $this->container->get('fos_user.user_manager')->updateUser($user, true);
210
211 $this->addFlash(
212 'notice',
213 'flashes.config.notice.otp_disabled'
214 );
215
216 return $this->redirect($this->generateUrl('config') . '#set3');
217 }
218
219 /**
196 * Enable 2FA using email. 220 * Enable 2FA using email.
197 * 221 *
198 * @Route("/config/otp/email", name="config_otp_email") 222 * @Route("/config/otp/email", name="config_otp_email")
@@ -220,6 +244,32 @@ class ConfigController extends Controller
220 } 244 }
221 245
222 /** 246 /**
247 * Disable 2FA using OTP app.
248 *
249 * @Route("/config/otp/app/disable", name="disable_otp_app")
250 */
251 public function disableOtpAppAction()
252 {
253 if (!$this->getParameter('twofactor_auth')) {
254 return $this->createNotFoundException('two_factor not enabled');
255 }
256
257 $user = $this->getUser();
258
259 $user->setGoogleAuthenticatorSecret('');
260 $user->setBackupCodes(null);
261
262 $this->container->get('fos_user.user_manager')->updateUser($user, true);
263
264 $this->addFlash(
265 'notice',
266 'flashes.config.notice.otp_disabled'
267 );
268
269 return $this->redirect($this->generateUrl('config') . '#set3');
270 }
271
272 /**
223 * Enable 2FA using OTP app, user will need to confirm the generated code from the app. 273 * Enable 2FA using OTP app, user will need to confirm the generated code from the app.
224 * 274 *
225 * @Route("/config/otp/app", name="config_otp_app") 275 * @Route("/config/otp/app", name="config_otp_app")
@@ -248,6 +298,11 @@ class ConfigController extends Controller
248 298
249 $this->container->get('fos_user.user_manager')->updateUser($user, true); 299 $this->container->get('fos_user.user_manager')->updateUser($user, true);
250 300
301 $this->addFlash(
302 'notice',
303 'flashes.config.notice.otp_enabled'
304 );
305
251 return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [ 306 return $this->render('WallabagCoreBundle:Config:otp_app.html.twig', [
252 'backupCodes' => $backupCodes, 307 'backupCodes' => $backupCodes,
253 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user), 308 'qr_code' => $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user),