🛂(frontend) redirect to the OIDC when private doc

We now redirect to the OIDC when a user is on
a private doc and is not authentified.
This commit is contained in:
Anthony LC
2024-09-27 15:52:43 +02:00
committed by Anthony LC
parent 413e0bebad
commit 1e89eb1a21
4 changed files with 38 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 3,
retry: 1,
},
},
});

View File

@@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
import { Box, Text } from '@/components';
import { TextErrors } from '@/components/TextErrors';
import { useAuthStore } from '@/core/auth';
import { DocEditor } from '@/features/docs';
import { useDoc } from '@/features/docs/doc-management';
import { MainLayout } from '@/layouts';
@@ -31,6 +32,7 @@ interface DocProps {
}
const DocPage = ({ id }: DocProps) => {
const { authenticated, login } = useAuthStore();
const { data: docQuery, isError, error } = useDoc({ id });
const [doc, setDoc] = useState(docQuery);
@@ -58,6 +60,11 @@ const DocPage = ({ id }: DocProps) => {
return null;
}
if (error.status === 401 && !authenticated) {
login();
return null;
}
return (
<Box $margin="large">
<TextErrors