File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1616use Cake \Core \Configure ;
1717use CakeDC \Auth \Authentication \AuthenticationService ;
1818use CakeDC \Auth \Authenticator \TwoFactorAuthenticator ;
19+ use CakeDC \Users \UsersPlugin ;
1920
2021trait OneTimePasswordVerifyTrait
2122{
@@ -43,6 +44,15 @@ public function verify()
4344 $ temporarySession = $ this ->getRequest ()->getSession ()->read (
4445 AuthenticationService::TWO_FACTOR_VERIFY_SESSION_KEY ,
4546 );
47+
48+ $ event = $ this ->dispatchEvent (UsersPlugin::EVENT_2FA_SKIP_VERIFY , ['user ' => $ temporarySession ]);
49+ if ($ event ->getResult () === true ) {
50+ $ this ->getRequest ()->getSession ()->delete (AuthenticationService::TWO_FACTOR_VERIFY_SESSION_KEY );
51+ $ this ->getRequest ()->getSession ()->write (TwoFactorAuthenticator::USER_SESSION_KEY , $ temporarySession );
52+
53+ return $ this ->redirect ($ loginAction );
54+ }
55+
4656 $ secretVerified = $ temporarySession ['secret_verified ' ] ?? null ;
4757 // showing QR-code until shared secret is verified
4858 if (!$ secretVerified ) {
@@ -55,7 +65,10 @@ public function verify()
5565 $ temporarySession ['email ' ],
5666 $ secret ,
5767 );
58- $ this ->set (['secretDataUri ' => $ secretDataUri ]);
68+ $ this ->set ([
69+ 'secretDataUri ' => $ secretDataUri ,
70+ 'secret ' => $ secret ,
71+ ]);
5972 }
6073
6174 if ($ this ->getRequest ()->is ('post ' )) {
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ class UsersPlugin extends BasePlugin
4848 public const EVENT_AFTER_RESEND_TOKEN_VALIDATION = 'Users.Global.afterResendTokenValidation ' ;
4949 public const EVENT_AFTER_EMAIL_TOKEN_VALIDATION = 'Users.Global.afterEmailTokenValidation ' ;
5050
51+ public const EVENT_2FA_SKIP_VERIFY = 'Users.TwoFactor.skipVerify ' ;
52+
5153 public const DEPRECATED_MESSAGE_U2F =
5254 'U2F is no longer supported by chrome, we suggest using Webauthn as a replacement ' ;
5355
You can’t perform that action at this time.
0 commit comments