Files
imphnen-frontend-service/libs/utils/src/hooks/use-session.ts
T

23 lines
422 B
TypeScript
Raw Normal View History

2025-04-03 12:21:10 +07:00
import { SessionToken, SessionUser } from '../local-storage';
export const useSession = () => {
const session = {
user: SessionUser.get(),
token: SessionToken.get(),
};
const isAuthenticated = !!session.token?.access_token;
const signOut = () => {
SessionUser.remove();
SessionToken.remove();
window.location.reload();
};
return {
isAuthenticated,
session,
signOut,
};
};