mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 18:09:40 +05:00
fix: opening auth only pages, without auth
now they are redirecting to the login page in that case
This commit is contained in:
parent
9e65838569
commit
d28011b4fb
6 changed files with 64 additions and 26 deletions
|
@ -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: () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue