We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1fcc70c commit 1b0625aCopy full SHA for 1b0625a
1 file changed
components/SessionGuard.tsx
@@ -1,12 +1,19 @@
1
'use client';
2
3
import { ReactNode, useEffect } from 'react';
4
+import { usePathname } from 'next/navigation';
5
import { signIn, useSession } from 'next-auth/react';
6
7
export default function SessionGuard({ children }: { children: ReactNode }) {
8
const { data } = useSession();
9
+
10
+ const pathname = usePathname();
11
12
useEffect(() => {
- if (data?.error === 'RefreshAccessTokenError') {
13
+ if (
14
+ data?.error === 'RefreshAccessTokenError' &&
15
+ pathname.includes('dashboard')
16
+ ) {
17
signIn('keycloak');
18
}
19
}, [data]);
0 commit comments