Skip to content

Commit 9e7a6a1

Browse files
committed
Fix 2fa code being accessible to user even after it is enabled
1 parent f27bb9b commit 9e7a6a1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Controller/UserController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ public function enableTwoFactorAuthAction(Request $req, #[VarName('name')] User
274274
throw $this->createAccessDeniedException('You cannot change this user\'s two-factor authentication settings');
275275
}
276276

277+
if ($user->isTotpAuthenticationEnabled()) {
278+
throw $this->createAccessDeniedException('Two-factor authentication is already enabled');
279+
}
280+
277281
$secret = (string) $req->getSession()->get('2fa_secret') ?: $authenticator->generateSecret();
278282
// Temporarily store this code on the user, as we'll need it there to generate the
279283
// QR code and to check the confirmation code. We won't actually save this change

0 commit comments

Comments
 (0)