fix auth redirect
This commit is contained in:
1 parent
906db7a908
commit
64e99676ab
2 files changed
+7
-3
No files matched your search
@@ -27,11 +27,12 @@ export const AuthUserProvider = ({children}: PropsWithChildren) => {
|
||||
try {
|
||||
const res = await axios.get('/api/user')
|
||||
setAuthUser(res.data)
|
||||
} catch (e) {
|
||||
} catch (error) {
|
||||
// @ts-expect-error check axios response status
|
||||
if (e.response.status === 401) {
|
||||
if (error.response.status === 401) {
|
||||
console.info('no user login')
|
||||
if (window.location.pathname !== '/connexion') {
|
||||
let url = window.location.pathname.split('/')[1]
|
||||
if (!['connexion', 'changer-le-mot-de-passe'].includes(url)) {
|
||||
window.location.href = '/connexion'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user