fix?: rerender when auth check finished

This commit is contained in:
Kentai Radiquum 2024-08-01 16:21:36 +05:00
parent e548ce060d
commit 8bab85ddc1
Signed by: Radiquum
GPG key ID: 858E8EE696525EED

View file

@ -23,9 +23,10 @@ export const useUserStore = create<userState>((set, get) => ({
set({ isAuth: false, user: null, token: null });
removeJWT();
},
checkAuth: async () => {
checkAuth: () => {
const jwt = getJWT();
if (jwt) {
const _checkAuth = async () => {
const data = await fetchDataViaGet(
`/api/profile/${jwt.user_id}?token=${jwt.jwt}`
);
@ -34,6 +35,8 @@ export const useUserStore = create<userState>((set, get) => ({
} else {
get().logout();
}
}
_checkAuth()
} else {
get().logout();
}