@@ -74,24 +74,23 @@ public function indexAction()
7474 }
7575 }
7676
77- if ($ user ->can ('user/two-factor-authentication ' )) {
78- $ twoFactor = TwoFactorTotp::loadFromDb ($ this ->getDb (), $ user ->getUsername ());
79- if ($ twoFactor === null ) {
80- $ twoFactor = TwoFactorTotp::generate ($ user ->getUsername ());
77+ $ twoFactor = TwoFactorTotp::loadFromDb ($ this ->getDb (), $ user ->getUsername ());
78+ if ($ twoFactor === null ) {
79+ $ twoFactor = TwoFactorTotp::generate ($ user ->getUsername ());
80+ }
81+
82+ $ twoFactorForm = new TwoFactorConfigForm ();
83+ $ twoFactorForm ->setUser ($ user );
84+ $ twoFactorForm ->setTwoFactor ($ twoFactor );
85+ $ twoFactorForm ->on (Form::ON_SUBMIT , function (TwoFactorConfigForm $ form ) {
86+ if ($ redirectUrl = $ form ->getRedirectUrl ()) {
87+ $ this ->redirectNow ($ redirectUrl );
8188 }
89+ });
90+ $ twoFactorForm ->handleRequest (ServerRequest::fromGlobals ());
8291
83- $ twoFactorForm = new TwoFactorConfigForm ();
84- $ twoFactorForm ->setUser ($ user );
85- $ twoFactorForm ->setTwoFactor ($ twoFactor );
86- $ twoFactorForm ->on (Form::ON_SUBMIT , function (TwoFactorConfigForm $ form ) {
87- if ($ redirectUrl = $ form ->getRedirectUrl ()) {
88- $ this ->redirectNow ($ redirectUrl );
89- }
90- });
91- $ twoFactorForm ->handleRequest (ServerRequest::fromGlobals ());
92+ $ this ->view ->twoFactorForm = $ twoFactorForm ;
9293
93- $ this ->view ->twoFactorForm = $ twoFactorForm ;
94- }
9594
9695 $ form = new PreferenceForm ();
9796 $ form ->setPreferences ($ user ->getPreferences ());
0 commit comments