feat: auth flow
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
const AUTH_TOKEN_KEY = "auth_token";
|
||||
|
||||
interface SessionState {
|
||||
token: string | null;
|
||||
setToken: (token: string) => void;
|
||||
clearToken: () => void;
|
||||
}
|
||||
|
||||
export const useSessionStore = create<SessionState>((set) => ({
|
||||
token: localStorage.getItem(AUTH_TOKEN_KEY),
|
||||
|
||||
setToken: (token: string) => {
|
||||
localStorage.setItem(AUTH_TOKEN_KEY, token);
|
||||
set({ token });
|
||||
},
|
||||
|
||||
clearToken: () => {
|
||||
localStorage.removeItem(AUTH_TOKEN_KEY);
|
||||
set({ token: null });
|
||||
},
|
||||
}));
|
||||
Reference in New Issue
Block a user