🛂(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:
@@ -16,8 +16,9 @@ and this project adheres to
|
|||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
- 🐛 (backend) gitlab oicd userinfo endpoint #232
|
- 🐛(backend) gitlab oicd userinfo endpoint #232
|
||||||
- ♻️ (backend) getting list of document versions available for a user #258
|
- 🛂(frontend) redirect to the OIDC when private doc and unauthentified #292
|
||||||
|
- ♻️(backend) getting list of document versions available for a user #258
|
||||||
|
|
||||||
## [1.4.0] - 2024-09-17
|
## [1.4.0] - 2024-09-17
|
||||||
|
|
||||||
|
|||||||
@@ -93,4 +93,31 @@ test.describe('Doc Visibility: Not loggued', () => {
|
|||||||
|
|
||||||
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
|
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('A private doc redirect to the OIDC when not authentified.', async ({
|
||||||
|
page,
|
||||||
|
browserName,
|
||||||
|
}) => {
|
||||||
|
test.slow();
|
||||||
|
await page.goto('/');
|
||||||
|
await keyCloakSignIn(page, browserName);
|
||||||
|
|
||||||
|
const [docTitle] = await createDoc(page, 'My private doc', browserName, 1);
|
||||||
|
|
||||||
|
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
|
||||||
|
|
||||||
|
const urlDoc = page.url();
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('button', {
|
||||||
|
name: 'Logout',
|
||||||
|
})
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible();
|
||||||
|
|
||||||
|
await page.goto(urlDoc);
|
||||||
|
|
||||||
|
await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const queryClient = new QueryClient({
|
|||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
staleTime: 1000 * 60 * 3,
|
staleTime: 1000 * 60 * 3,
|
||||||
|
retry: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
|
|||||||
|
|
||||||
import { Box, Text } from '@/components';
|
import { Box, Text } from '@/components';
|
||||||
import { TextErrors } from '@/components/TextErrors';
|
import { TextErrors } from '@/components/TextErrors';
|
||||||
|
import { useAuthStore } from '@/core/auth';
|
||||||
import { DocEditor } from '@/features/docs';
|
import { DocEditor } from '@/features/docs';
|
||||||
import { useDoc } from '@/features/docs/doc-management';
|
import { useDoc } from '@/features/docs/doc-management';
|
||||||
import { MainLayout } from '@/layouts';
|
import { MainLayout } from '@/layouts';
|
||||||
@@ -31,6 +32,7 @@ interface DocProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DocPage = ({ id }: DocProps) => {
|
const DocPage = ({ id }: DocProps) => {
|
||||||
|
const { authenticated, 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);
|
||||||
|
|
||||||
@@ -58,6 +60,11 @@ const DocPage = ({ id }: DocProps) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (error.status === 401 && !authenticated) {
|
||||||
|
login();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box $margin="large">
|
<Box $margin="large">
|
||||||
<TextErrors
|
<TextErrors
|
||||||
|
|||||||
Reference in New Issue
Block a user