diff --git a/app/store/auth.ts b/app/store/auth.ts index 45c4364..1489174 100644 --- a/app/store/auth.ts +++ b/app/store/auth.ts @@ -23,17 +23,20 @@ export const useUserStore = create((set, get) => ({ set({ isAuth: false, user: null, token: null }); removeJWT(); }, - checkAuth: async () => { + checkAuth: () => { const jwt = getJWT(); if (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); - } else { - get().logout(); + const _checkAuth = async () => { + const data = await fetchDataViaGet( + `/api/profile/${jwt.user_id}?token=${jwt.jwt}` + ); + if (data && data.is_my_profile) { + get().login(data.profile, jwt.jwt); + } else { + get().logout(); + } } + _checkAuth() } else { get().logout(); }