File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,15 +29,14 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
2929 return `single` ;
3030 }
3131
32- private saveChallengeToStorage ( challenge : string , expiresIn ?: string ) : void {
32+ private useChellenge ( challenge : string , expiresIn ?: string ) : void {
3333 const expiresInSeconds = expiresIn ? convertPeriodToSeconds ( expiresIn ) : undefined ;
3434 this . options . passkeys . keyValueAdapter . set ( challenge , 'stub_value' , expiresInSeconds ) ;
3535 }
3636
37- private async checkIfChallengeInBlackList ( challenge : string ) : Promise < boolean > {
37+ private async checkIfChellengeNotUsed ( challenge : string ) : Promise < boolean > {
3838 const res = await this . options . passkeys . keyValueAdapter . get ( challenge ) ;
3939 if ( ! res ) {
40- this . saveChallengeToStorage ( challenge , this . options . passkeys ?. challengeValidityPeriod || '2m' ) ;
4140 return true ;
4241 }
4342 return false ;
@@ -50,7 +49,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
5049 }
5150
5251 const decodedPasskeysCookies = await this . adminforth . auth . verify ( passkeysCookies , 'tempLoginPasskeyChallenge' , false ) ;
53- const isChallangeValid = await this . checkIfChallengeInBlackList ( decodedPasskeysCookies . challenge ) ;
52+ const isChallangeValid = await this . checkIfChellengeNotUsed ( decodedPasskeysCookies . challenge ) ;
53+ if ( isChallangeValid ) {
54+ this . useChellenge ( decodedPasskeysCookies . challenge , this . options . passkeys ?. challengeValidityPeriod || '2m' ) ;
55+ }
5456
5557 if ( ! decodedPasskeysCookies || ! isChallangeValid ) {
5658 return { ok : false , error : 'Invalid passkey' } ;
You can’t perform that action at this time.
0 commit comments