1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-27 17:28:39 +00:00

Remove twofactor_auth parameter

Fix #6649
This commit is contained in:
Nicolas Lœuillet 2023-07-15 16:10:18 +02:00
parent 2c1687ce91
commit c75d3e6961
8 changed files with 36 additions and 78 deletions

View file

@ -85,19 +85,17 @@ class ManageController extends AbstractController
$form->handleRequest($request);
// `googleTwoFactor` isn't a field within the User entity, we need to define it's value in a different way
if ($this->getParameter('twofactor_auth') && true === $user->isGoogleAuthenticatorEnabled() && false === $form->isSubmitted()) {
if (true === $user->isGoogleAuthenticatorEnabled() && false === $form->isSubmitted()) {
$form->get('googleTwoFactor')->setData(true);
}
if ($form->isSubmitted() && $form->isValid()) {
// handle creation / reset of the OTP secret if checkbox changed from the previous state
if ($this->getParameter('twofactor_auth')) {
if (true === $form->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) {
$user->setGoogleAuthenticatorSecret($googleAuthenticator->generateSecret());
$user->setEmailTwoFactor(false);
} elseif (false === $form->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) {
$user->setGoogleAuthenticatorSecret(null);
}
if (true === $form->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) {
$user->setGoogleAuthenticatorSecret($googleAuthenticator->generateSecret());
$user->setEmailTwoFactor(false);
} elseif (false === $form->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) {
$user->setGoogleAuthenticatorSecret(null);
}
$userManager->updateUser($user);
@ -114,7 +112,6 @@ class ManageController extends AbstractController
'user' => $user,
'edit_form' => $form->createView(),
'delete_form' => $deleteForm->createView(),
'twofactor_auth' => $this->getParameter('twofactor_auth'),
]);
}