feat: saving auth

This commit is contained in:
Kentai Radiquum 2024-07-14 12:56:50 +05:00
parent 5aa8b1103e
commit c4a9b4f91a
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
3 changed files with 67 additions and 14 deletions

View file

@ -8,7 +8,7 @@ export const useUserStore = create((set, get) => ({
token: null,
login: (user, token) => {
set({ isAuth: true, user, token });
set({ isAuth: true, user: user, token: token });
},
logout: () => {
set({ isAuth: false, user: null, token: null });
@ -21,7 +21,7 @@ export const useUserStore = create((set, get) => ({
`/api/profile/${jwt.user_id}?token=${jwt.jwt}`
);
if (data && data.is_my_profile) {
get().login(data, jwt.user_id, jwt.jwt);
get().login(data.profile, jwt.jwt);
} else {
get().logout();
}