Files
imphnen-frontend-service/libs/utils/src/hooks/use-session.ts
T
2025-11-25 01:47:56 +07:00

22 lines
513 B
TypeScript

import { supabase } from '@imphnen-frontend-service/service';
import { useAuthStore } from './';
import { useNavigate } from 'react-router';
export const useSession = () => {
const navigate = useNavigate();
const { clearSession, session, status } = useAuthStore();
const isAuthenticated = status === 'authenticated';
const signOut = async () => {
await supabase.auth.signOut();
clearSession();
navigate('/auth/login');
};
return {
session,
signOut,
isAuthenticated,
};
};