@adminforth/two-factors-auth 1.0.30 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.0.30] - 2024-12-13
2
+
3
+ ### Fixed
4
+
5
+ - Fixed skip 2fa
6
+
1
7
  ## [1.0.20] - 2024-12-05
2
8
 
3
9
  ### Added
@@ -187,6 +187,9 @@ const handleSkip = async () => {
187
187
  const resp = await callAdminForthApi({
188
188
  method: 'POST',
189
189
  path: '/plugin/twofa/confirmSetup',
190
+ body: {
191
+ skip: true,
192
+ }
190
193
  });
191
194
  if (resp.allowedLogin){
192
195
  await user.finishLogin()
File without changes
@@ -187,6 +187,9 @@ const handleSkip = async () => {
187
187
  const resp = await callAdminForthApi({
188
188
  method: 'POST',
189
189
  path: '/plugin/twofa/confirmSetup',
190
+ body: {
191
+ skip: true,
192
+ }
190
193
  });
191
194
  if (resp.allowedLogin){
192
195
  await user.finishLogin()
package/dist/index.js CHANGED
@@ -109,10 +109,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
109
109
  return { status: 'error', message: 'Invalid token' };
110
110
  }
111
111
  if (decoded.newSecret) {
112
- const verified = decoded.userCanSkipSetup ? true : twofactor.verifyToken(decoded.newSecret, body.code);
112
+ const verified = body.skip && decoded.userCanSkipSetup ? true : twofactor.verifyToken(decoded.newSecret, body.code);
113
113
  if (verified) {
114
114
  this.connectors = this.adminforth.connectors;
115
- if (!decoded.userCanSkipSetup) {
115
+ if (!body.skip) {
116
116
  const connector = this.connectors[this.authResource.dataSource];
117
117
  yield connector.updateRecord({ resource: this.authResource, recordId: decoded.pk, newValues: { [this.options.twoFaSecretFieldName]: decoded.newSecret } });
118
118
  }
package/index.ts CHANGED
@@ -117,10 +117,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
117
117
  return {status:'error',message:'Invalid token'}
118
118
  }
119
119
  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);
121
121
  if (verified) {
122
122
  this.connectors = this.adminforth.connectors
123
- if (!decoded.userCanSkipSetup) {
123
+ if (!body.skip) {
124
124
  const connector = this.connectors[this.authResource.dataSource];
125
125
  await connector.updateRecord({resource:this.authResource, recordId:decoded.pk, newValues:{[this.options.twoFaSecretFieldName]: decoded.newSecret}})
126
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",