@adminforth/two-factors-auth 1.10.5 → 1.10.7
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 +3 -2
- package/custom/TwoFactorsConfirmation.vue +24 -69
- package/custom/TwoFactorsPasskeysSettings.vue +2 -2
- package/custom/TwoFactorsSetup.vue +12 -2
- package/custom/utils.js +55 -0
- package/dist/custom/TwoFactorsConfirmation.vue +24 -69
- package/dist/custom/TwoFactorsPasskeysSettings.vue +2 -2
- package/dist/custom/TwoFactorsSetup.vue +12 -2
- package/dist/custom/utils.js +55 -0
- package/dist/index.js +4 -4
- package/index.ts +4 -4
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -11,6 +11,7 @@ custom/TwoFactorsSetup.vue
|
|
|
11
11
|
custom/package-lock.json
|
|
12
12
|
custom/package.json
|
|
13
13
|
custom/tsconfig.json
|
|
14
|
+
custom/utils.js
|
|
14
15
|
|
|
15
|
-
sent
|
|
16
|
-
total size is 57,
|
|
16
|
+
sent 58,612 bytes received 172 bytes 117,568.00 bytes/sec
|
|
17
|
+
total size is 57,985 speedup is 0.99
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
|
|
75
75
|
<script setup lang="ts">
|
|
76
76
|
|
|
77
|
-
import { onMounted, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
|
77
|
+
import { onMounted, nextTick, onBeforeUnmount, ref, watch, onBeforeMount } from 'vue';
|
|
78
78
|
import { useCoreStore } from '@/stores/core';
|
|
79
79
|
import { useUserStore } from '@/stores/user';
|
|
80
80
|
import { callAdminForthApi, loadFile } from '@/utils';
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
import { useRouter } from 'vue-router';
|
|
87
87
|
import { IconShieldOutline } from '@iconify-prerendered/vue-flowbite';
|
|
88
88
|
import ErrorMessage from '@/components/ErrorMessage.vue';
|
|
89
|
+
import { handlePasskeyAlert } from './utils.js';
|
|
89
90
|
|
|
90
91
|
const { t } = useI18n();
|
|
91
92
|
const code = ref(null);
|
|
@@ -95,6 +96,17 @@
|
|
|
95
96
|
const router = useRouter();
|
|
96
97
|
const codeError = ref(null);
|
|
97
98
|
|
|
99
|
+
onBeforeMount(() => {
|
|
100
|
+
if (localStorage.getItem('isAuthorized') === 'true') {
|
|
101
|
+
coreStore.fetchMenuAndResource();
|
|
102
|
+
if (route.query.next) {
|
|
103
|
+
router.push(route.query.next.toString());
|
|
104
|
+
} else {
|
|
105
|
+
router.push({ name: 'home' });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
98
110
|
const handleOnComplete = (value) => {
|
|
99
111
|
sendCode(value, 'TOTP', null);
|
|
100
112
|
};
|
|
@@ -121,16 +133,18 @@
|
|
|
121
133
|
const isPasskeysSupported = ref(false);
|
|
122
134
|
|
|
123
135
|
onMounted(async () => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
if (localStorage.getItem('isAuthorized') !== 'true') {
|
|
137
|
+
await nextTick();
|
|
138
|
+
await isCMAAvailable();
|
|
139
|
+
tagOtpInputs();
|
|
140
|
+
if (isPasskeysSupported.value === true) {
|
|
141
|
+
checkIfUserHasPasskeys();
|
|
142
|
+
}
|
|
143
|
+
document.addEventListener('focusin', handleGlobalFocusIn, true);
|
|
144
|
+
focusFirstAvailableOtpInput();
|
|
145
|
+
const rootEl = otpRoot.value;
|
|
146
|
+
rootEl && rootEl.addEventListener('focusout', handleFocusOut, true);
|
|
129
147
|
}
|
|
130
|
-
document.addEventListener('focusin', handleGlobalFocusIn, true);
|
|
131
|
-
focusFirstAvailableOtpInput();
|
|
132
|
-
const rootEl = otpRoot.value;
|
|
133
|
-
rootEl && rootEl.addEventListener('focusout', handleFocusOut, true);
|
|
134
148
|
});
|
|
135
149
|
|
|
136
150
|
watch(route, (newRoute) => {
|
|
@@ -265,65 +279,6 @@
|
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
|
|
268
|
-
</script>
|
|
269
|
-
|
|
270
|
-
<script lang="ts">
|
|
271
|
-
|
|
272
|
-
export function handlePasskeyAlert(propSuggestionPeriod, router) {
|
|
273
|
-
const currentDate = Date.now();
|
|
274
|
-
window.localStorage.removeItem('suggestionPeriod');
|
|
275
|
-
window.localStorage.setItem('suggestionPeriod', propSuggestionPeriod);
|
|
276
|
-
let suggestionPeriod = window.localStorage.getItem('suggestionPeriod');
|
|
277
|
-
let lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
278
|
-
let suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
279
|
-
if ( !lastSuggestionDate ) {
|
|
280
|
-
window.localStorage.setItem('lastSuggestionDate', currentDate.toString());
|
|
281
|
-
lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
282
|
-
}
|
|
283
|
-
if ( !suggestPasskey ) {
|
|
284
|
-
window.localStorage.setItem('suggestPasskey', 'true');
|
|
285
|
-
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
286
|
-
}
|
|
287
|
-
if ( currentDate - parseInt(lastSuggestionDate) > parseInt(suggestionPeriod) ) {
|
|
288
|
-
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
289
|
-
if (suggestPasskey !== 'true'){
|
|
290
|
-
if ( suggestPasskey === 'false' || !suggestPasskey ) {
|
|
291
|
-
window.localStorage.setItem('suggestPasskey', 'true');
|
|
292
|
-
} else if ( suggestPasskey !== 'never' ) {
|
|
293
|
-
window.localStorage.setItem('suggestPasskey', 'false');
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
298
|
-
|
|
299
|
-
if ( suggestPasskey === 'true' ) {
|
|
300
|
-
adminforth.alert({
|
|
301
|
-
message: 'Do you want to add passkey?',
|
|
302
|
-
variant: 'info',
|
|
303
|
-
buttons: [
|
|
304
|
-
{ value: 'yes', label: 'Add passkey' },
|
|
305
|
-
{ value: 'later', label: 'Later' },
|
|
306
|
-
{ value: 'never', label: 'Never' },
|
|
307
|
-
],
|
|
308
|
-
timeout: 'unlimited'
|
|
309
|
-
}).then((value) => {
|
|
310
|
-
switch (value) {
|
|
311
|
-
case 'yes':
|
|
312
|
-
router.push({ name: 'settings', params: { page: 'passkeys' } });
|
|
313
|
-
break;
|
|
314
|
-
case 'later':
|
|
315
|
-
window.localStorage.setItem('suggestPasskey', 'false');
|
|
316
|
-
break;
|
|
317
|
-
case 'never':
|
|
318
|
-
window.localStorage.setItem('suggestPasskey', 'never');
|
|
319
|
-
break;
|
|
320
|
-
default:
|
|
321
|
-
window.localStorage.setItem('suggestPasskey', 'false');
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
282
|
|
|
328
283
|
function getOtpInputs() {
|
|
329
284
|
const root = otpRoot.value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="text-3xl text-gray-900 font-semibold
|
|
3
|
-
<p>Passkeys</p>
|
|
2
|
+
<div class="text-3xl text-gray-900 font-semibold max-w-2xl mr-6 flex-col justify-center items-center">
|
|
3
|
+
<p class="flex items-start justify-start leading-none">Passkeys</p>
|
|
4
4
|
<div class="flex flex-col items-end">
|
|
5
5
|
<Table
|
|
6
6
|
class="mt-4 w-full"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
|
|
68
68
|
<script setup lang="ts">
|
|
69
69
|
|
|
70
|
-
import { onMounted, onBeforeUnmount, nextTick, ref, watchEffect,computed,watch } from 'vue';
|
|
70
|
+
import { onMounted, onBeforeUnmount, nextTick, ref, watchEffect,computed,watch, onBeforeMount } from 'vue';
|
|
71
71
|
import { useCoreStore } from '@/stores/core';
|
|
72
72
|
import { useUserStore } from '@/stores/user';
|
|
73
73
|
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
@@ -80,12 +80,22 @@ import VOtpInput from "vue3-otp-input";
|
|
|
80
80
|
import adminforth from '@/adminforth';
|
|
81
81
|
import { useI18n } from 'vue-i18n';
|
|
82
82
|
import { useRoute } from 'vue-router';
|
|
83
|
-
import { handlePasskeyAlert } from './
|
|
83
|
+
import { handlePasskeyAlert } from './utils.js';
|
|
84
84
|
import ErrorMessage from '@/components/ErrorMessage.vue';
|
|
85
85
|
|
|
86
86
|
const { t } = useI18n();
|
|
87
87
|
const route = useRoute()
|
|
88
88
|
|
|
89
|
+
onBeforeMount(() => {
|
|
90
|
+
if (localStorage.getItem('isAuthorized') === 'true') {
|
|
91
|
+
coreStore.fetchMenuAndResource();
|
|
92
|
+
if (route.query.next) {
|
|
93
|
+
router.push(route.query.next.toString());
|
|
94
|
+
} else {
|
|
95
|
+
router.push({ name: 'home' });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
89
99
|
|
|
90
100
|
const code = ref(null);
|
|
91
101
|
const codeError = ref(null);
|
package/custom/utils.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export function handlePasskeyAlert(propSuggestionPeriod, router) {
|
|
2
|
+
const currentDate = Date.now();
|
|
3
|
+
window.localStorage.removeItem('suggestionPeriod');
|
|
4
|
+
window.localStorage.setItem('suggestionPeriod', propSuggestionPeriod);
|
|
5
|
+
let suggestionPeriod = window.localStorage.getItem('suggestionPeriod');
|
|
6
|
+
let lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
7
|
+
let suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
8
|
+
if ( !lastSuggestionDate ) {
|
|
9
|
+
window.localStorage.setItem('lastSuggestionDate', currentDate.toString());
|
|
10
|
+
lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
11
|
+
}
|
|
12
|
+
if ( !suggestPasskey ) {
|
|
13
|
+
window.localStorage.setItem('suggestPasskey', 'true');
|
|
14
|
+
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
15
|
+
}
|
|
16
|
+
if ( currentDate - parseInt(lastSuggestionDate) > parseInt(suggestionPeriod) ) {
|
|
17
|
+
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
18
|
+
if (suggestPasskey !== 'true'){
|
|
19
|
+
if ( suggestPasskey === 'false' || !suggestPasskey ) {
|
|
20
|
+
window.localStorage.setItem('suggestPasskey', 'true');
|
|
21
|
+
} else if ( suggestPasskey !== 'never' ) {
|
|
22
|
+
window.localStorage.setItem('suggestPasskey', 'false');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
27
|
+
|
|
28
|
+
if ( suggestPasskey === 'true' ) {
|
|
29
|
+
adminforth.alert({
|
|
30
|
+
message: 'Do you want to add passkey?',
|
|
31
|
+
variant: 'info',
|
|
32
|
+
buttons: [
|
|
33
|
+
{ value: 'yes', label: 'Add passkey' },
|
|
34
|
+
{ value: 'later', label: 'Later' },
|
|
35
|
+
{ value: 'never', label: 'Never' },
|
|
36
|
+
],
|
|
37
|
+
timeout: 'unlimited'
|
|
38
|
+
}).then((value) => {
|
|
39
|
+
switch (value) {
|
|
40
|
+
case 'yes':
|
|
41
|
+
router.push({ name: 'settings', params: { page: 'passkeys' } });
|
|
42
|
+
break;
|
|
43
|
+
case 'later':
|
|
44
|
+
window.localStorage.setItem('suggestPasskey', 'false');
|
|
45
|
+
break;
|
|
46
|
+
case 'never':
|
|
47
|
+
window.localStorage.setItem('suggestPasskey', 'never');
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
window.localStorage.setItem('suggestPasskey', 'false');
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
|
|
75
75
|
<script setup lang="ts">
|
|
76
76
|
|
|
77
|
-
import { onMounted, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
|
77
|
+
import { onMounted, nextTick, onBeforeUnmount, ref, watch, onBeforeMount } from 'vue';
|
|
78
78
|
import { useCoreStore } from '@/stores/core';
|
|
79
79
|
import { useUserStore } from '@/stores/user';
|
|
80
80
|
import { callAdminForthApi, loadFile } from '@/utils';
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
import { useRouter } from 'vue-router';
|
|
87
87
|
import { IconShieldOutline } from '@iconify-prerendered/vue-flowbite';
|
|
88
88
|
import ErrorMessage from '@/components/ErrorMessage.vue';
|
|
89
|
+
import { handlePasskeyAlert } from './utils.js';
|
|
89
90
|
|
|
90
91
|
const { t } = useI18n();
|
|
91
92
|
const code = ref(null);
|
|
@@ -95,6 +96,17 @@
|
|
|
95
96
|
const router = useRouter();
|
|
96
97
|
const codeError = ref(null);
|
|
97
98
|
|
|
99
|
+
onBeforeMount(() => {
|
|
100
|
+
if (localStorage.getItem('isAuthorized') === 'true') {
|
|
101
|
+
coreStore.fetchMenuAndResource();
|
|
102
|
+
if (route.query.next) {
|
|
103
|
+
router.push(route.query.next.toString());
|
|
104
|
+
} else {
|
|
105
|
+
router.push({ name: 'home' });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
|
|
98
110
|
const handleOnComplete = (value) => {
|
|
99
111
|
sendCode(value, 'TOTP', null);
|
|
100
112
|
};
|
|
@@ -121,16 +133,18 @@
|
|
|
121
133
|
const isPasskeysSupported = ref(false);
|
|
122
134
|
|
|
123
135
|
onMounted(async () => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
if (localStorage.getItem('isAuthorized') !== 'true') {
|
|
137
|
+
await nextTick();
|
|
138
|
+
await isCMAAvailable();
|
|
139
|
+
tagOtpInputs();
|
|
140
|
+
if (isPasskeysSupported.value === true) {
|
|
141
|
+
checkIfUserHasPasskeys();
|
|
142
|
+
}
|
|
143
|
+
document.addEventListener('focusin', handleGlobalFocusIn, true);
|
|
144
|
+
focusFirstAvailableOtpInput();
|
|
145
|
+
const rootEl = otpRoot.value;
|
|
146
|
+
rootEl && rootEl.addEventListener('focusout', handleFocusOut, true);
|
|
129
147
|
}
|
|
130
|
-
document.addEventListener('focusin', handleGlobalFocusIn, true);
|
|
131
|
-
focusFirstAvailableOtpInput();
|
|
132
|
-
const rootEl = otpRoot.value;
|
|
133
|
-
rootEl && rootEl.addEventListener('focusout', handleFocusOut, true);
|
|
134
148
|
});
|
|
135
149
|
|
|
136
150
|
watch(route, (newRoute) => {
|
|
@@ -265,65 +279,6 @@
|
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
|
|
268
|
-
</script>
|
|
269
|
-
|
|
270
|
-
<script lang="ts">
|
|
271
|
-
|
|
272
|
-
export function handlePasskeyAlert(propSuggestionPeriod, router) {
|
|
273
|
-
const currentDate = Date.now();
|
|
274
|
-
window.localStorage.removeItem('suggestionPeriod');
|
|
275
|
-
window.localStorage.setItem('suggestionPeriod', propSuggestionPeriod);
|
|
276
|
-
let suggestionPeriod = window.localStorage.getItem('suggestionPeriod');
|
|
277
|
-
let lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
278
|
-
let suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
279
|
-
if ( !lastSuggestionDate ) {
|
|
280
|
-
window.localStorage.setItem('lastSuggestionDate', currentDate.toString());
|
|
281
|
-
lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
282
|
-
}
|
|
283
|
-
if ( !suggestPasskey ) {
|
|
284
|
-
window.localStorage.setItem('suggestPasskey', 'true');
|
|
285
|
-
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
286
|
-
}
|
|
287
|
-
if ( currentDate - parseInt(lastSuggestionDate) > parseInt(suggestionPeriod) ) {
|
|
288
|
-
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
289
|
-
if (suggestPasskey !== 'true'){
|
|
290
|
-
if ( suggestPasskey === 'false' || !suggestPasskey ) {
|
|
291
|
-
window.localStorage.setItem('suggestPasskey', 'true');
|
|
292
|
-
} else if ( suggestPasskey !== 'never' ) {
|
|
293
|
-
window.localStorage.setItem('suggestPasskey', 'false');
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
298
|
-
|
|
299
|
-
if ( suggestPasskey === 'true' ) {
|
|
300
|
-
adminforth.alert({
|
|
301
|
-
message: 'Do you want to add passkey?',
|
|
302
|
-
variant: 'info',
|
|
303
|
-
buttons: [
|
|
304
|
-
{ value: 'yes', label: 'Add passkey' },
|
|
305
|
-
{ value: 'later', label: 'Later' },
|
|
306
|
-
{ value: 'never', label: 'Never' },
|
|
307
|
-
],
|
|
308
|
-
timeout: 'unlimited'
|
|
309
|
-
}).then((value) => {
|
|
310
|
-
switch (value) {
|
|
311
|
-
case 'yes':
|
|
312
|
-
router.push({ name: 'settings', params: { page: 'passkeys' } });
|
|
313
|
-
break;
|
|
314
|
-
case 'later':
|
|
315
|
-
window.localStorage.setItem('suggestPasskey', 'false');
|
|
316
|
-
break;
|
|
317
|
-
case 'never':
|
|
318
|
-
window.localStorage.setItem('suggestPasskey', 'never');
|
|
319
|
-
break;
|
|
320
|
-
default:
|
|
321
|
-
window.localStorage.setItem('suggestPasskey', 'false');
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
282
|
|
|
328
283
|
function getOtpInputs() {
|
|
329
284
|
const root = otpRoot.value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="text-3xl text-gray-900 font-semibold
|
|
3
|
-
<p>Passkeys</p>
|
|
2
|
+
<div class="text-3xl text-gray-900 font-semibold max-w-2xl mr-6 flex-col justify-center items-center">
|
|
3
|
+
<p class="flex items-start justify-start leading-none">Passkeys</p>
|
|
4
4
|
<div class="flex flex-col items-end">
|
|
5
5
|
<Table
|
|
6
6
|
class="mt-4 w-full"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
|
|
68
68
|
<script setup lang="ts">
|
|
69
69
|
|
|
70
|
-
import { onMounted, onBeforeUnmount, nextTick, ref, watchEffect,computed,watch } from 'vue';
|
|
70
|
+
import { onMounted, onBeforeUnmount, nextTick, ref, watchEffect,computed,watch, onBeforeMount } from 'vue';
|
|
71
71
|
import { useCoreStore } from '@/stores/core';
|
|
72
72
|
import { useUserStore } from '@/stores/user';
|
|
73
73
|
import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbite';
|
|
@@ -80,12 +80,22 @@ import VOtpInput from "vue3-otp-input";
|
|
|
80
80
|
import adminforth from '@/adminforth';
|
|
81
81
|
import { useI18n } from 'vue-i18n';
|
|
82
82
|
import { useRoute } from 'vue-router';
|
|
83
|
-
import { handlePasskeyAlert } from './
|
|
83
|
+
import { handlePasskeyAlert } from './utils.js';
|
|
84
84
|
import ErrorMessage from '@/components/ErrorMessage.vue';
|
|
85
85
|
|
|
86
86
|
const { t } = useI18n();
|
|
87
87
|
const route = useRoute()
|
|
88
88
|
|
|
89
|
+
onBeforeMount(() => {
|
|
90
|
+
if (localStorage.getItem('isAuthorized') === 'true') {
|
|
91
|
+
coreStore.fetchMenuAndResource();
|
|
92
|
+
if (route.query.next) {
|
|
93
|
+
router.push(route.query.next.toString());
|
|
94
|
+
} else {
|
|
95
|
+
router.push({ name: 'home' });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
89
99
|
|
|
90
100
|
const code = ref(null);
|
|
91
101
|
const codeError = ref(null);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export function handlePasskeyAlert(propSuggestionPeriod, router) {
|
|
2
|
+
const currentDate = Date.now();
|
|
3
|
+
window.localStorage.removeItem('suggestionPeriod');
|
|
4
|
+
window.localStorage.setItem('suggestionPeriod', propSuggestionPeriod);
|
|
5
|
+
let suggestionPeriod = window.localStorage.getItem('suggestionPeriod');
|
|
6
|
+
let lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
7
|
+
let suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
8
|
+
if ( !lastSuggestionDate ) {
|
|
9
|
+
window.localStorage.setItem('lastSuggestionDate', currentDate.toString());
|
|
10
|
+
lastSuggestionDate = window.localStorage.getItem('lastSuggestionDate');
|
|
11
|
+
}
|
|
12
|
+
if ( !suggestPasskey ) {
|
|
13
|
+
window.localStorage.setItem('suggestPasskey', 'true');
|
|
14
|
+
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
15
|
+
}
|
|
16
|
+
if ( currentDate - parseInt(lastSuggestionDate) > parseInt(suggestionPeriod) ) {
|
|
17
|
+
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
18
|
+
if (suggestPasskey !== 'true'){
|
|
19
|
+
if ( suggestPasskey === 'false' || !suggestPasskey ) {
|
|
20
|
+
window.localStorage.setItem('suggestPasskey', 'true');
|
|
21
|
+
} else if ( suggestPasskey !== 'never' ) {
|
|
22
|
+
window.localStorage.setItem('suggestPasskey', 'false');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
suggestPasskey = window.localStorage.getItem('suggestPasskey');
|
|
27
|
+
|
|
28
|
+
if ( suggestPasskey === 'true' ) {
|
|
29
|
+
adminforth.alert({
|
|
30
|
+
message: 'Do you want to add passkey?',
|
|
31
|
+
variant: 'info',
|
|
32
|
+
buttons: [
|
|
33
|
+
{ value: 'yes', label: 'Add passkey' },
|
|
34
|
+
{ value: 'later', label: 'Later' },
|
|
35
|
+
{ value: 'never', label: 'Never' },
|
|
36
|
+
],
|
|
37
|
+
timeout: 'unlimited'
|
|
38
|
+
}).then((value) => {
|
|
39
|
+
switch (value) {
|
|
40
|
+
case 'yes':
|
|
41
|
+
router.push({ name: 'settings', params: { page: 'passkeys' } });
|
|
42
|
+
break;
|
|
43
|
+
case 'later':
|
|
44
|
+
window.localStorage.setItem('suggestPasskey', 'false');
|
|
45
|
+
break;
|
|
46
|
+
case 'never':
|
|
47
|
+
window.localStorage.setItem('suggestPasskey', 'never');
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
window.localStorage.setItem('suggestPasskey', 'false');
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
71
71
|
const response = JSON.parse(body.response);
|
|
72
72
|
try {
|
|
73
73
|
if (settingsOrigin !== expectedOrigin) {
|
|
74
|
-
throw new Error(
|
|
74
|
+
throw new Error(`Origin mismatch. Allowed in settings: ${settingsOrigin}, received from client: ${expectedOrigin}`);
|
|
75
75
|
}
|
|
76
76
|
const cred = yield this.adminforth.resource(this.options.passkeys.credentialResourceID).get([Filters.EQ(this.options.passkeys.credentialIdFieldName, response.id)]);
|
|
77
77
|
if (!cred) {
|
|
@@ -92,7 +92,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
92
92
|
const { verified, authenticationInfo } = yield verifyAuthenticationResponse({
|
|
93
93
|
response,
|
|
94
94
|
expectedChallenge,
|
|
95
|
-
expectedOrigin,
|
|
95
|
+
expectedOrigin: settingsOrigin,
|
|
96
96
|
expectedRPID,
|
|
97
97
|
credential: {
|
|
98
98
|
id: cred[this.options.passkeys.credentialIdFieldName],
|
|
@@ -125,11 +125,11 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
125
125
|
const customPages = this.adminforth.config.customization.customPages;
|
|
126
126
|
customPages.push({
|
|
127
127
|
path: '/confirm2fa',
|
|
128
|
-
component: { file: this.componentPath('TwoFactorsConfirmation.vue'), meta: {
|
|
128
|
+
component: { file: this.componentPath('TwoFactorsConfirmation.vue'), meta: { sidebarAndHeader: "none", suggestionPeriod: suggestionPeriod, isPasskeysEnabled: isPasskeysEnabled } }
|
|
129
129
|
});
|
|
130
130
|
customPages.push({
|
|
131
131
|
path: '/setup2fa',
|
|
132
|
-
component: { file: this.componentPath('TwoFactorsSetup.vue'), meta: { title: 'Setup 2FA',
|
|
132
|
+
component: { file: this.componentPath('TwoFactorsSetup.vue'), meta: { title: 'Setup 2FA', sidebarAndHeader: "none", suggestionPeriod: suggestionPeriod, isPasskeysEnabled: isPasskeysEnabled } }
|
|
133
133
|
});
|
|
134
134
|
const everyPageBottomInjections = this.adminforth.config.customization.globalInjections.everyPageBottom || [];
|
|
135
135
|
everyPageBottomInjections.push({ file: this.componentPath('TwoFAModal.vue'), meta: {} });
|
package/index.ts
CHANGED
|
@@ -80,7 +80,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
80
80
|
const response = JSON.parse(body.response);
|
|
81
81
|
try {
|
|
82
82
|
if (settingsOrigin !== expectedOrigin) {
|
|
83
|
-
throw new Error(
|
|
83
|
+
throw new Error(`Origin mismatch. Allowed in settings: ${settingsOrigin}, received from client: ${expectedOrigin}`);
|
|
84
84
|
}
|
|
85
85
|
const cred = await this.adminforth.resource(this.options.passkeys.credentialResourceID).get([Filters.EQ(this.options.passkeys.credentialIdFieldName, response.id)]);
|
|
86
86
|
if (!cred) {
|
|
@@ -101,7 +101,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
101
101
|
const { verified, authenticationInfo } = await verifyAuthenticationResponse({
|
|
102
102
|
response,
|
|
103
103
|
expectedChallenge,
|
|
104
|
-
expectedOrigin,
|
|
104
|
+
expectedOrigin: settingsOrigin,
|
|
105
105
|
expectedRPID,
|
|
106
106
|
credential: {
|
|
107
107
|
id: cred[this.options.passkeys.credentialIdFieldName],
|
|
@@ -134,11 +134,11 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
134
134
|
const customPages = this.adminforth.config.customization.customPages
|
|
135
135
|
customPages.push({
|
|
136
136
|
path:'/confirm2fa',
|
|
137
|
-
component: { file: this.componentPath('TwoFactorsConfirmation.vue'), meta: {
|
|
137
|
+
component: { file: this.componentPath('TwoFactorsConfirmation.vue'), meta: { sidebarAndHeader: "none", suggestionPeriod: suggestionPeriod, isPasskeysEnabled: isPasskeysEnabled } }
|
|
138
138
|
})
|
|
139
139
|
customPages.push({
|
|
140
140
|
path:'/setup2fa',
|
|
141
|
-
component: { file: this.componentPath('TwoFactorsSetup.vue'), meta: { title: 'Setup 2FA',
|
|
141
|
+
component: { file: this.componentPath('TwoFactorsSetup.vue'), meta: { title: 'Setup 2FA', sidebarAndHeader: "none", suggestionPeriod: suggestionPeriod, isPasskeysEnabled: isPasskeysEnabled } }
|
|
142
142
|
})
|
|
143
143
|
const everyPageBottomInjections = this.adminforth.config.customization.globalInjections.everyPageBottom || []
|
|
144
144
|
everyPageBottomInjections.push({ file: this.componentPath('TwoFAModal.vue'), meta: {} })
|