mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-07 00:34:41 +00:00
fix?: rerender when auth check finished
This commit is contained in:
parent
e548ce060d
commit
8bab85ddc1
1 changed files with 11 additions and 8 deletions
|
@ -23,17 +23,20 @@ export const useUserStore = create<userState>((set, get) => ({
|
||||||
set({ isAuth: false, user: null, token: null });
|
set({ isAuth: false, user: null, token: null });
|
||||||
removeJWT();
|
removeJWT();
|
||||||
},
|
},
|
||||||
checkAuth: async () => {
|
checkAuth: () => {
|
||||||
const jwt = getJWT();
|
const jwt = getJWT();
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
const data = await fetchDataViaGet(
|
const _checkAuth = async () => {
|
||||||
`/api/profile/${jwt.user_id}?token=${jwt.jwt}`
|
const data = await fetchDataViaGet(
|
||||||
);
|
`/api/profile/${jwt.user_id}?token=${jwt.jwt}`
|
||||||
if (data && data.is_my_profile) {
|
);
|
||||||
get().login(data.profile, jwt.jwt);
|
if (data && data.is_my_profile) {
|
||||||
} else {
|
get().login(data.profile, jwt.jwt);
|
||||||
get().logout();
|
} else {
|
||||||
|
get().logout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_checkAuth()
|
||||||
} else {
|
} else {
|
||||||
get().logout();
|
get().logout();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue