fix: show snackbar on invalid password
parent
af7e775216
commit
8bedf4fe55
|
|
@ -48,8 +48,8 @@ const isSnackbarVisibility = ref(false)
|
||||||
const useUserStore = userStore()
|
const useUserStore = userStore()
|
||||||
|
|
||||||
const login = async () => {
|
const login = async () => {
|
||||||
// update the userStore with the user data
|
try {
|
||||||
useUserStore.login(credentials.value.username, credentials.value.password, ability)
|
await useUserStore.login(credentials.value.username, credentials.value.password, ability)
|
||||||
|
|
||||||
// Redirect to `to` query if exist or redirect to index route
|
// Redirect to `to` query if exist or redirect to index route
|
||||||
// ❗ nextTick is required to wait for DOM updates and later redirect
|
// ❗ nextTick is required to wait for DOM updates and later redirect
|
||||||
|
|
@ -57,6 +57,10 @@ const login = async () => {
|
||||||
router.replace(route.query.to ? String(route.query.to) : '/')
|
router.replace(route.query.to ? String(route.query.to) : '/')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
catch (err) {
|
||||||
|
isSnackbarVisibility.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
refVForm.value?.validate()
|
refVForm.value?.validate()
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,9 @@ export const userStore = defineStore('user', {
|
||||||
useCookie('userAbilityRules').value = rules
|
useCookie('userAbilityRules').value = rules
|
||||||
ability.update(rules)
|
ability.update(rules)
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err: any) {
|
||||||
console.error(err)
|
console.log(err.message)
|
||||||
|
throw err // Rethrow the error so it can be caught in the component
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,9 @@ export const $api = ofetch.create({
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
options.headers = {
|
options.headers = {
|
||||||
...options.headers,
|
...options.headers,
|
||||||
'Authorization': `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
'Cache-Control': 'no-cache',
|
|
||||||
|
// 'Cache-Control': 'no-cache',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue