@adminforth/two-factors-auth 2.0.2 → 2.0.3

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/build.log CHANGED
@@ -13,5 +13,5 @@ custom/package.json
13
13
  custom/tsconfig.json
14
14
  custom/utils.js
15
15
 
16
- sent 68,638 bytes received 172 bytes 137,620.00 bytes/sec
17
- total size is 67,998 speedup is 0.99
16
+ sent 68,919 bytes received 172 bytes 138,182.00 bytes/sec
17
+ total size is 68,279 speedup is 0.99
@@ -11,11 +11,11 @@
11
11
  <div v-if="isLoading===false" id="authentication-modal" tabindex="-1" class="af-two-factors-confirmation overflow-y-auto overflow-x-hidden z-50 min-w-[00px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
12
12
  <div class="relative p-4 w-full max-w-md max-h-full">
13
13
  <!-- Modal content -->
14
- <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black text-gray-500" >
14
+ <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black text-gray-500" :class="codeError ? 'rounded-b-none' : ''">
15
15
  <div class="p-8 w-full max-w-md max-h-full custom-auth-wrapper" >
16
16
  <div v-if="confirmationMode === 'code'">
17
- <div id="mfaCode-label" class="m-4">{{$t('Please enter your authenticator code')}} </div>
18
- <div class="my-4 w-full flex flex-col gap-4 justify-center" ref="otpRoot">
17
+ <div id="mfaCode-label" class="mx-4">{{$t('Please enter your authenticator code')}} </div>
18
+ <div class="mt-4 w-full flex flex-col gap-4 justify-center" ref="otpRoot">
19
19
  <v-otp-input
20
20
  ref="code"
21
21
  container-class="grid grid-cols-6 gap-3 w-full"
@@ -64,8 +64,16 @@
64
64
  </div>
65
65
  </div>
66
66
  </div>
67
- <ErrorMessage :error="codeError" />
68
67
  </div>
68
+ <div
69
+ v-if="codeError"
70
+ class="relative top-full left-0 bg-red-100 text-red-700 text-sm px-2 py-2 rounded-b-lg shadow"
71
+ >
72
+ <p class="pl-6">{{ codeError }} </p>
73
+ </div>
74
+ <div v-else class="h-[36px]">
75
+
76
+ </div>
69
77
  </div>
70
78
  </div>
71
79
  <div v-else>
@@ -11,11 +11,11 @@
11
11
  <div v-if="isLoading===false" id="authentication-modal" tabindex="-1" class="af-two-factors-confirmation overflow-y-auto overflow-x-hidden z-50 min-w-[00px] justify-center items-center md:inset-0 h-[calc(100%-1rem)] max-h-full">
12
12
  <div class="relative p-4 w-full max-w-md max-h-full">
13
13
  <!-- Modal content -->
14
- <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black text-gray-500" >
14
+ <div class="relative bg-white rounded-lg shadow dark:bg-gray-700 dark:shadow-black text-gray-500" :class="codeError ? 'rounded-b-none' : ''">
15
15
  <div class="p-8 w-full max-w-md max-h-full custom-auth-wrapper" >
16
16
  <div v-if="confirmationMode === 'code'">
17
- <div id="mfaCode-label" class="m-4">{{$t('Please enter your authenticator code')}} </div>
18
- <div class="my-4 w-full flex flex-col gap-4 justify-center" ref="otpRoot">
17
+ <div id="mfaCode-label" class="mx-4">{{$t('Please enter your authenticator code')}} </div>
18
+ <div class="mt-4 w-full flex flex-col gap-4 justify-center" ref="otpRoot">
19
19
  <v-otp-input
20
20
  ref="code"
21
21
  container-class="grid grid-cols-6 gap-3 w-full"
@@ -64,8 +64,16 @@
64
64
  </div>
65
65
  </div>
66
66
  </div>
67
- <ErrorMessage :error="codeError" />
68
67
  </div>
68
+ <div
69
+ v-if="codeError"
70
+ class="relative top-full left-0 bg-red-100 text-red-700 text-sm px-2 py-2 rounded-b-lg shadow"
71
+ >
72
+ <p class="pl-6">{{ codeError }} </p>
73
+ </div>
74
+ <div v-else class="h-[36px]">
75
+
76
+ </div>
69
77
  </div>
70
78
  </div>
71
79
  <div v-else>
package/dist/index.js CHANGED
@@ -314,9 +314,12 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
314
314
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, response, cookies }) {
315
315
  const brandNameSlug = this.adminforth.config.customization.brandNameSlug;
316
316
  const totpTemporaryJWT = this.adminforth.auth.getCustomCookie({ cookies: cookies, name: "2FaTemporaryJWT" });
317
+ if (!totpTemporaryJWT) {
318
+ return { error: 'Login session expired. Please log in again.' };
319
+ }
317
320
  const decoded = yield this.adminforth.auth.verify(totpTemporaryJWT, 'temp2FA');
318
321
  if (!decoded) {
319
- return { status: 'error', message: 'Login session expired. Please log in again.' };
322
+ return { error: 'Login session expired. Please log in again.' };
320
323
  }
321
324
  if (decoded.newSecret) {
322
325
  // set up standard TOTP request - ensured by presence of newSecret in temp2FA token
package/index.ts CHANGED
@@ -355,9 +355,12 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
355
355
  handler: async ({ body, adminUser, response, cookies }) => {
356
356
  const brandNameSlug = this.adminforth.config.customization.brandNameSlug;
357
357
  const totpTemporaryJWT = this.adminforth.auth.getCustomCookie({cookies: cookies, name: "2FaTemporaryJWT"});
358
+ if (!totpTemporaryJWT) {
359
+ return { error: 'Login session expired. Please log in again.' }
360
+ }
358
361
  const decoded = await this.adminforth.auth.verify(totpTemporaryJWT, 'temp2FA');
359
362
  if (!decoded) {
360
- return { status:'error', message:'Login session expired. Please log in again.' }
363
+ return { error: 'Login session expired. Please log in again.' }
361
364
  }
362
365
 
363
366
  if (decoded.newSecret) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",