fix: opening auth only pages, without auth

now they are redirecting to the login page in that case
This commit is contained in:
Kentai Radiquum 2024-08-04 14:14:52 +05:00
parent 9e65838569
commit d28011b4fb
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
6 changed files with 64 additions and 26 deletions

View file

@ -6,6 +6,7 @@ interface userState {
isAuth: boolean
user: Object | null
token: string | null
state: string,
login: (user: Object, token: string) => void
logout: () => void
checkAuth: () => void
@ -15,12 +16,13 @@ export const useUserStore = create<userState>((set, get) => ({
isAuth: false,
user: null,
token: null,
state: "loading",
login: (user: Object, token: string) => {
set({ isAuth: true, user: user, token: token });
set({ isAuth: true, user: user, token: token, state: "finished" });
},
logout: () => {
set({ isAuth: false, user: null, token: null });
set({ isAuth: false, user: null, token: null, state: "finished" });
removeJWT();
},
checkAuth: () => {