mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-27 23:41:56 +02:00
Reset the user store on unauthenticated HTTP response
This commit is contained in:
parent
73e36edd9c
commit
fe9002501b
@ -1,4 +1,5 @@
|
||||
import axios from "axios"
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
export const httpClientFactory = (endpoint = 'api') => {
|
||||
let baseURL
|
||||
@ -26,10 +27,9 @@ export const httpClientFactory = (endpoint = 'api') => {
|
||||
if (
|
||||
error.response &&
|
||||
[401, 419].includes(error.response.status)
|
||||
// && store.getters["auth/authUser"] &&
|
||||
// !store.getters["auth/guest"]
|
||||
) {
|
||||
// store.dispatch("auth/logout");
|
||||
const user = useUserStore()
|
||||
user.reset()
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
10
resources/js_vue3/stores/user.js
vendored
10
resources/js_vue3/stores/user.js
vendored
@ -34,14 +34,18 @@ export const useUserStore = defineStore({
|
||||
}
|
||||
else {
|
||||
return authService.logout().then(() => {
|
||||
localStorage.clear()
|
||||
this.$reset()
|
||||
router.push({ name: 'login' })
|
||||
this.reset()
|
||||
})
|
||||
|
||||
// this.$router.push({ name: 'login', params: { forceRefresh: true } })
|
||||
}
|
||||
// },
|
||||
},
|
||||
|
||||
reset() {
|
||||
localStorage.clear()
|
||||
this.$reset()
|
||||
router.push({ name: 'login' })
|
||||
}
|
||||
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user