Skip to content

Commit 5413f72

Browse files
committed
update
1 parent b06bc93 commit 5413f72

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

spec/AuthenticationAdapters.spec.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,9 @@ describe('OTP TOTP auth adatper', () => {
24732473
username: 'username',
24742474
password: 'password',
24752475
authData: {
2476-
mfa: totp.generate(),
2476+
mfa: {
2477+
token: totp.generate(),
2478+
},
24772479
},
24782480
}),
24792481
}).then(res => res.data);
@@ -2608,7 +2610,9 @@ describe('OTP TOTP auth adatper', () => {
26082610
username: 'username',
26092611
password: 'password',
26102612
authData: {
2611-
mfa: 'abcd',
2613+
mfa: {
2614+
token: 'abcd',
2615+
},
26122616
},
26132617
}),
26142618
}).catch(e => {
@@ -2694,7 +2698,9 @@ describe('OTP SMS auth adatper', () => {
26942698
username: 'username',
26952699
password: 'password',
26962700
authData: {
2697-
mfa: true,
2701+
mfa: {
2702+
token: 'request',
2703+
},
26982704
},
26992705
}),
27002706
}).catch(e => e.data);
@@ -2708,7 +2714,9 @@ describe('OTP SMS auth adatper', () => {
27082714
username: 'username',
27092715
password: 'password',
27102716
authData: {
2711-
mfa: code,
2717+
mfa: {
2718+
token: code,
2719+
},
27122720
},
27132721
}),
27142722
}).then(res => res.data);

src/Adapters/Auth/mfa.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ class MFAAdapter extends AuthAdapter {
4444
}
4545
throw 'Invalid MFA data';
4646
}
47-
async validateLogin(token, _, req) {
47+
async validateLogin(loginData, _, req) {
4848
const saveResponse = {
4949
doNotSave: true,
5050
};
51+
const token = loginData.token;
5152
const auth = req.original.get('authData') || {};
5253
const { secret, recovery, mobile, token: saved, expiry } = auth.mfa || {};
5354
if (this.sms && mobile) {
54-
if (typeof token === 'boolean') {
55+
if (token === 'request') {
5556
const { token: sendToken, expiry } = await this.sendSMS(mobile);
5657
auth.mfa.token = sendToken;
5758
auth.mfa.expiry = expiry;
@@ -107,7 +108,7 @@ class MFAAdapter extends AuthAdapter {
107108
return this.confirmSMSOTP(authData, req.original.get('authData')?.mfa || {});
108109
}
109110
if (this.totp) {
110-
await this.validateLogin(authData.old, null, req);
111+
await this.validateLogin({ token: authData.old }, null, req);
111112
return this.validateSetUp(authData);
112113
}
113114
throw 'Invalid MFA data';

0 commit comments

Comments
 (0)