+3
-1
src/webapp/hooks/useAuth.tsx
+3
-1
src/webapp/hooks/useAuth.tsx
···
6
6
import type { GetProfileResponse } from '@/api-client/ApiClient';
7
7
import { ClientCookieAuthService } from '@/services/auth/CookieAuthService.client';
8
8
import { verifySessionOnClient } from '@/lib/auth/dal';
9
+
import { usePathname } from 'next/navigation';
9
10
10
11
interface AuthContextType {
11
12
user: GetProfileResponse | null;
···
20
21
export const AuthProvider = ({ children }: { children: ReactNode }) => {
21
22
const router = useRouter();
22
23
const queryClient = useQueryClient();
24
+
const pathname = usePathname(); // to prevent redirecting to login on landing page
23
25
24
26
const refreshAuth = async () => {
25
27
await query.refetch();
···
43
45
});
44
46
45
47
useEffect(() => {
46
-
if (query.isError && !query.isLoading) logout();
48
+
if (query.isError && !query.isLoading && pathname !== '/') logout();
47
49
}, [query.isError, logout]);
48
50
49
51
const contextValue: AuthContextType = {