-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSO - Correction des erreurs de connexion (#3763)
## Linked issues - Resolve #3759 - Suppression de ApiError pour n'utiliser que FrontendApiError - Utilisation d'un `<RequireAuth/>`, sur le même principe que sur MonitorEnv ---- - [ ] Tests E2E (Cypress)
- Loading branch information
Showing
64 changed files
with
731 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line import/no-import-module-exports | ||
import { noop } from 'lodash' | ||
|
||
module.exports = noop | ||
module.exports.ReactComponent = noop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
context('Authorization', () => { | ||
beforeEach(() => { | ||
cy.loadPath('/#@-824534.42,6082993.21,8.70') | ||
}) | ||
|
||
it('Should redirect to login page if an API request is Unauthorized', () => { | ||
// When | ||
cy.intercept('GET', `/bff/v1/vessels/search*`, { statusCode: 401 }).as('searchVessel') | ||
cy.get('*[data-cy^="vessel-search-input"]', { timeout: 10000 }).type('Pheno') | ||
cy.wait('@searchVessel') | ||
|
||
// Then | ||
cy.location('pathname').should('eq', '/login') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,33 @@ | ||
import { CustomGlobalStyle } from '@components/CustomGlobalStyle' | ||
import { FrontendErrorBoundary } from '@components/FrontendErrorBoundary' | ||
import { GlobalStyle, THEME, ThemeProvider } from '@mtes-mct/monitor-ui' | ||
import { LandingPage } from '@pages/LandingPage' | ||
import { UnsupportedBrowserPage } from '@pages/UnsupportedBrowserPage' | ||
import { isBrowserSupported } from '@utils/isBrowserSupported' | ||
import { UserAccountContext } from 'context/UserAccountContext' | ||
import countries from 'i18n-iso-countries' | ||
import COUNTRIES_FR from 'i18n-iso-countries/langs/fr.json' | ||
import { RouterProvider } from 'react-router-dom' | ||
import { CustomProvider as RsuiteCustomProvider } from 'rsuite' | ||
import rsuiteFrFr from 'rsuite/locales/fr_FR' | ||
|
||
import { useCustomAuth } from './auth/hooks/useCustomAuth' | ||
import { router } from './router' | ||
|
||
countries.registerLocale(COUNTRIES_FR) | ||
|
||
export function App() { | ||
const { isAuthorized, isLoading, userAccount } = useCustomAuth() | ||
|
||
if (isLoading) { | ||
return <LandingPage /> | ||
} | ||
|
||
if (!isAuthorized || !userAccount) { | ||
return <LandingPage hasInsufficientRights /> | ||
} | ||
|
||
if (!isBrowserSupported()) { | ||
return <UnsupportedBrowserPage /> | ||
} | ||
|
||
return ( | ||
<UserAccountContext.Provider value={userAccount}> | ||
<ThemeProvider theme={THEME}> | ||
<GlobalStyle /> | ||
<CustomGlobalStyle /> | ||
|
||
<RsuiteCustomProvider locale={rsuiteFrFr}> | ||
<FrontendErrorBoundary> | ||
<RouterProvider router={router} /> | ||
</FrontendErrorBoundary> | ||
</RsuiteCustomProvider> | ||
</ThemeProvider> | ||
</UserAccountContext.Provider> | ||
<ThemeProvider theme={THEME}> | ||
<GlobalStyle /> | ||
<CustomGlobalStyle /> | ||
|
||
<RsuiteCustomProvider locale={rsuiteFrFr}> | ||
<FrontendErrorBoundary> | ||
<RouterProvider router={router} /> | ||
</FrontendErrorBoundary> | ||
</RsuiteCustomProvider> | ||
</ThemeProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.