45
45
name =" username"
46
46
id =" username"
47
47
ref =" usernameInput"
48
+ oninput =" setCustomValidity('')"
48
49
@keydown.enter =" passwordInput.focus()"
49
50
class =" bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder =" name@company.com" required />
50
51
</div >
53
54
<input
54
55
ref =" passwordInput"
55
56
autocomplete =" current-password"
57
+ oninput =" setCustomValidity('')"
56
58
@keydown.enter =" login"
57
59
:type =" !showPw ? 'password': 'text'" name =" password" id =" password" placeholder =" ••••••••" class =" bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" required />
58
60
<button type =" button" @click =" showPw = !showPw" class =" absolute top-12 right-3 -translate-y-1/2 text-gray-400 dark:text-gray-300" >
@@ -120,6 +122,9 @@ import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbi
120
122
import { callAdminForthApi , loadFile } from ' @/utils' ;
121
123
import { useRoute , useRouter } from ' vue-router' ;
122
124
import { Button , Checkbox } from ' @/afcl' ;
125
+ import { useI18n } from ' vue-i18n' ;
126
+
127
+ const { t } = useI18n ();
123
128
124
129
const passwordInput = ref (null );
125
130
const usernameInput = ref (null );
@@ -167,9 +172,15 @@ async function login() {
167
172
const username = usernameInput .value .value ;
168
173
const password = passwordInput .value .value ;
169
174
170
- if (! username || ! password) {
175
+ if (! username) {
176
+ usernameInput .value .setCustomValidity (t (' Please fill out this field.' ));
177
+ return ;
178
+ }
179
+ if (! password) {
180
+ passwordInput .value .setCustomValidity (t (' Please fill out this field.' ));
171
181
return ;
172
182
}
183
+
173
184
if (inProgress .value ) {
174
185
return ;
175
186
}
@@ -184,7 +195,7 @@ async function login() {
184
195
}
185
196
});
186
197
if (resp .error ) {
187
- error .value = resp .error ;
198
+ error .value = resp .error ;
188
199
} else if (resp .redirectTo ) {
189
200
router .push (resp .redirectTo );
190
201
} else {
0 commit comments