+ // handle creation / reset of the OTP secret if checkbox changed from the previous state
+ if (true === $userForm->get('googleTwoFactor')->getData() && false === $user->isGoogleAuthenticatorEnabled()) {
+ $secret = $this->get('scheb_two_factor.security.google_authenticator')->generateSecret();
+
+ $user->setGoogleAuthenticatorSecret($secret);
+ $user->setEmailTwoFactor(false);
+
+ $qrCode = $this->get('scheb_two_factor.security.google_authenticator')->getQRContent($user);
+
+ $this->addFlash('OTPSecret', ['code' => $secret, 'qrCode' => $qrCode]);
+ } elseif (false === $userForm->get('googleTwoFactor')->getData() && true === $user->isGoogleAuthenticatorEnabled()) {
+ $user->setGoogleAuthenticatorSecret(null);
+ }
+