4545 name =" username"
4646 id =" username"
4747 ref =" usernameInput"
48+ oninput =" setCustomValidity('')"
4849 @keydown.enter =" passwordInput.focus()"
4950 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 />
5051 </div >
@@ -120,6 +121,9 @@ import { IconEyeSolid, IconEyeSlashSolid } from '@iconify-prerendered/vue-flowbi
120121import { callAdminForthApi , loadFile } from ' @/utils' ;
121122import { useRoute , useRouter } from ' vue-router' ;
122123import { Button , Checkbox } from ' @/afcl' ;
124+ import { useI18n } from ' vue-i18n' ;
125+
126+ const { t } = useI18n ();
123127
124128const passwordInput = ref (null );
125129const usernameInput = ref (null );
@@ -167,9 +171,15 @@ async function login() {
167171 const username = usernameInput .value .value ;
168172 const password = passwordInput .value .value ;
169173
170- if (! username || ! password) {
174+ if (! username) {
175+ usernameInput .value .setCustomValidity (t (' Please fill out this field.' ));
176+ return ;
177+ }
178+ if (! password) {
179+ passwordInput .value .setCustomValidity (t (' Please fill out this field.' ));
171180 return ;
172181 }
182+
173183 if (inProgress .value ) {
174184 return ;
175185 }
@@ -184,7 +194,11 @@ async function login() {
184194 }
185195 });
186196 if (resp .error ) {
187- error .value = resp .error ;
197+ if (resp .error === ' invalid_username_or_password' ) {
198+ error .value = t (' Invalid username or password' );
199+ } else {
200+ error .value = resp .error ;
201+ }
188202 } else if (resp .redirectTo ) {
189203 router .push (resp .redirectTo );
190204 } else {
0 commit comments