@adminforth/two-factors-auth 1.8.9 → 1.9.0

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
@@ -11,5 +11,5 @@ custom/package-lock.json
11
11
  custom/package.json
12
12
  custom/tsconfig.json
13
13
 
14
- sent 31,500 bytes received 134 bytes 63,268.00 bytes/sec
15
- total size is 31,002 speedup is 0.98
14
+ sent 31,846 bytes received 134 bytes 63,960.00 bytes/sec
15
+ total size is 31,348 speedup is 0.98
@@ -80,13 +80,16 @@
80
80
  function tagOtpInputs() {
81
81
  const root = otpRoot.value;
82
82
  if (!root) return;
83
- root.querySelectorAll('input.otp-input').forEach((el, idx) => {
83
+ const inputs = root.querySelectorAll('input.otp-input');
84
+ inputs.forEach((el, idx) => {
84
85
  el.setAttribute('name', 'mfaCode');
85
86
  el.setAttribute('id', `mfaCode-${idx + 1}`);
86
87
  el.setAttribute('autocomplete', 'one-time-code');
87
88
  el.setAttribute('inputmode', 'numeric');
88
89
  el.setAttribute('aria-labelledby', 'mfaCode-label');
89
90
  });
91
+ (inputs[0] as HTMLInputElement)?.focus();
92
+
90
93
  }
91
94
 
92
95
  function handlePaste(event: ClipboardEvent) {
@@ -28,14 +28,15 @@
28
28
  @on-complete="handleOnComplete"
29
29
  />
30
30
  </div>
31
- <div class="mt-6 flex justify-center">
32
- <LinkButton
33
- to="/login"
34
- class="w-full"
35
- >
36
- {{$t('Back to login')}}
37
- </LinkButton>
38
- </div>
31
+ <ErrorMessage :error="codeError" />
32
+ <div class="mt-6 flex justify-center">
33
+ <LinkButton
34
+ to="/login"
35
+ class="w-full"
36
+ >
37
+ {{$t('Back to login')}}
38
+ </LinkButton>
39
+ </div>
39
40
  </div>
40
41
  </div>
41
42
  </div>
@@ -57,11 +58,13 @@
57
58
  import { LinkButton } from '@/afcl';
58
59
  import VOtpInput from "vue3-otp-input";
59
60
  import { useI18n } from 'vue-i18n';
61
+ import ErrorMessage from '@/components/ErrorMessage.vue';
60
62
 
61
63
  const { t } = useI18n();
62
64
  const code = ref(null);
63
65
  const otpRoot = ref(null);
64
66
  const bindValue = ref('');
67
+ const codeError = ref(null);
65
68
 
66
69
  const handleOnComplete = (value) => {
67
70
  sendCode(value);
@@ -108,7 +111,7 @@
108
111
  if (resp.allowedLogin){
109
112
  await user.finishLogin();
110
113
  } else {
111
- showErrorTost(t('Invalid code'));
114
+ codeError.value = 'Invalid code';
112
115
  }
113
116
  }
114
117
 
@@ -45,6 +45,7 @@
45
45
  @on-complete="handleOnComplete"
46
46
  />
47
47
  </div>
48
+ <ErrorMessage :error="codeError" />
48
49
  <!-- <Vue2FACodeInput v-model="code" autofocus /> -->
49
50
  <div class="flex flex-row gap-2.5 h-12">
50
51
  <LinkButton to="/login" class="w-full">
@@ -78,10 +79,12 @@ import Vue2FACodeInput from '@loltech/vue3-2fa-code-input';
78
79
  import VOtpInput from "vue3-otp-input";
79
80
  import adminforth from '@/adminforth';
80
81
  import { useI18n } from 'vue-i18n';
82
+ import ErrorMessage from '@/components/ErrorMessage.vue';
81
83
 
82
84
  const { t } = useI18n();
83
85
 
84
86
  const code = ref(null);
87
+ const codeError = ref(null);
85
88
  const handleOnComplete = (value) => {
86
89
  sendCode(value);
87
90
  };
@@ -187,7 +190,7 @@ async function sendCode (value) {
187
190
  if (resp.allowedLogin){
188
191
  await user.finishLogin()
189
192
  } else {
190
- showErrorTost(t('Invalid code'));
193
+ codeError.value = 'Invalid code';
191
194
  }
192
195
  }
193
196
 
@@ -214,7 +217,7 @@ const handleSkip = async () => {
214
217
  if (resp.allowedLogin){
215
218
  await user.finishLogin()
216
219
  } else {
217
- showErrorTost(t('Something went wrong'));
220
+ codeError.value = 'Something went wrong';
218
221
  }
219
222
  }
220
223
  </script>
@@ -80,13 +80,16 @@
80
80
  function tagOtpInputs() {
81
81
  const root = otpRoot.value;
82
82
  if (!root) return;
83
- root.querySelectorAll('input.otp-input').forEach((el, idx) => {
83
+ const inputs = root.querySelectorAll('input.otp-input');
84
+ inputs.forEach((el, idx) => {
84
85
  el.setAttribute('name', 'mfaCode');
85
86
  el.setAttribute('id', `mfaCode-${idx + 1}`);
86
87
  el.setAttribute('autocomplete', 'one-time-code');
87
88
  el.setAttribute('inputmode', 'numeric');
88
89
  el.setAttribute('aria-labelledby', 'mfaCode-label');
89
90
  });
91
+ (inputs[0] as HTMLInputElement)?.focus();
92
+
90
93
  }
91
94
 
92
95
  function handlePaste(event: ClipboardEvent) {
@@ -28,14 +28,15 @@
28
28
  @on-complete="handleOnComplete"
29
29
  />
30
30
  </div>
31
- <div class="mt-6 flex justify-center">
32
- <LinkButton
33
- to="/login"
34
- class="w-full"
35
- >
36
- {{$t('Back to login')}}
37
- </LinkButton>
38
- </div>
31
+ <ErrorMessage :error="codeError" />
32
+ <div class="mt-6 flex justify-center">
33
+ <LinkButton
34
+ to="/login"
35
+ class="w-full"
36
+ >
37
+ {{$t('Back to login')}}
38
+ </LinkButton>
39
+ </div>
39
40
  </div>
40
41
  </div>
41
42
  </div>
@@ -57,11 +58,13 @@
57
58
  import { LinkButton } from '@/afcl';
58
59
  import VOtpInput from "vue3-otp-input";
59
60
  import { useI18n } from 'vue-i18n';
61
+ import ErrorMessage from '@/components/ErrorMessage.vue';
60
62
 
61
63
  const { t } = useI18n();
62
64
  const code = ref(null);
63
65
  const otpRoot = ref(null);
64
66
  const bindValue = ref('');
67
+ const codeError = ref(null);
65
68
 
66
69
  const handleOnComplete = (value) => {
67
70
  sendCode(value);
@@ -108,7 +111,7 @@
108
111
  if (resp.allowedLogin){
109
112
  await user.finishLogin();
110
113
  } else {
111
- showErrorTost(t('Invalid code'));
114
+ codeError.value = 'Invalid code';
112
115
  }
113
116
  }
114
117
 
@@ -45,6 +45,7 @@
45
45
  @on-complete="handleOnComplete"
46
46
  />
47
47
  </div>
48
+ <ErrorMessage :error="codeError" />
48
49
  <!-- <Vue2FACodeInput v-model="code" autofocus /> -->
49
50
  <div class="flex flex-row gap-2.5 h-12">
50
51
  <LinkButton to="/login" class="w-full">
@@ -78,10 +79,12 @@ import Vue2FACodeInput from '@loltech/vue3-2fa-code-input';
78
79
  import VOtpInput from "vue3-otp-input";
79
80
  import adminforth from '@/adminforth';
80
81
  import { useI18n } from 'vue-i18n';
82
+ import ErrorMessage from '@/components/ErrorMessage.vue';
81
83
 
82
84
  const { t } = useI18n();
83
85
 
84
86
  const code = ref(null);
87
+ const codeError = ref(null);
85
88
  const handleOnComplete = (value) => {
86
89
  sendCode(value);
87
90
  };
@@ -187,7 +190,7 @@ async function sendCode (value) {
187
190
  if (resp.allowedLogin){
188
191
  await user.finishLogin()
189
192
  } else {
190
- showErrorTost(t('Invalid code'));
193
+ codeError.value = 'Invalid code';
191
194
  }
192
195
  }
193
196
 
@@ -214,7 +217,7 @@ const handleSkip = async () => {
214
217
  if (resp.allowedLogin){
215
218
  await user.finishLogin()
216
219
  } else {
217
- showErrorTost(t('Something went wrong'));
220
+ codeError.value = 'Something went wrong';
218
221
  }
219
222
  }
220
223
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "1.8.9",
3
+ "version": "1.9.0",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",