mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-19 18:04:22 +02:00
Fix names
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
||||
import { useAuthStore } from '@/renderer/store';
|
||||
|
||||
interface PrivateOutletProps {
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
const location = useLocation();
|
||||
const isAuthenticated = useAuthStore((state) => !!state.accessToken);
|
||||
const logout = useAuthStore((state) => state.logout);
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
logout();
|
||||
return <Navigate replace state={{ from: location }} to={redirectTo} />;
|
||||
};
|
||||
Reference in New Issue
Block a user