Skip to content

Commit 38ab4e1

Browse files
Fixed skip 2fa
1 parent a00bcb9 commit 38ab4e1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

adminforth/plugins/two-factors-auth/custom/TwoFactorsSetup.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ const handleSkip = async () => {
187187
const resp = await callAdminForthApi({
188188
method: 'POST',
189189
path: '/plugin/twofa/confirmSetup',
190+
body: {
191+
skip: true,
192+
}
190193
});
191194
if (resp.allowedLogin){
192195
await user.finishLogin()

adminforth/plugins/two-factors-auth/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
117117
return {status:'error',message:'Invalid token'}
118118
}
119119
if (decoded.newSecret) {
120-
const verified = decoded.userCanSkipSetup ? true : twofactor.verifyToken(decoded.newSecret, body.code);
120+
const verified = body.skip && decoded.userCanSkipSetup ? true : twofactor.verifyToken(decoded.newSecret, body.code);
121121
if (verified) {
122122
this.connectors = this.adminforth.connectors
123-
if (!decoded.userCanSkipSetup) {
123+
if (!body.skip) {
124124
const connector = this.connectors[this.authResource.dataSource];
125125
await connector.updateRecord({resource:this.authResource, recordId:decoded.pk, newValues:{[this.options.twoFaSecretFieldName]: decoded.newSecret}})
126126
}

0 commit comments

Comments
 (0)