🛂(frontend) redirect to the OIDC when private doc

We now redirect to the OIDC when a user is on
a private doc and get a 401 error.
This commit is contained in:
Anthony LC
2024-10-01 15:40:39 +02:00
committed by Anthony LC
parent f00f833ee2
commit 002b9340e3

View File

@@ -32,7 +32,7 @@ interface DocProps {
} }
const DocPage = ({ id }: DocProps) => { const DocPage = ({ id }: DocProps) => {
const { authenticated, login } = useAuthStore(); const { login } = useAuthStore();
const { data: docQuery, isError, error } = useDoc({ id }); const { data: docQuery, isError, error } = useDoc({ id });
const [doc, setDoc] = useState(docQuery); const [doc, setDoc] = useState(docQuery);
@@ -60,7 +60,7 @@ const DocPage = ({ id }: DocProps) => {
return null; return null;
} }
if (error.status === 401 && !authenticated) { if (error.status === 401) {
login(); login();
return null; return null;
} }