Skip to content

Commit

Permalink
:feat configuration de la déconnexion si erreur
Browse files Browse the repository at this point in the history
  • Loading branch information
dienamo committed Oct 8, 2024
1 parent 879d1f1 commit b6f04d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { AuthProvider } from 'react-oidc-context';
import { WebStorageStateStore } from 'oidc-client-ts';
import { BrowserRouter as Router } from 'react-router-dom';
import setup from './services/api';
import signInCallBack from '../src/services/auth/signInCallBack';
import { MatomoProvider, createInstance } from '@jonkoops/matomo-tracker-react';

if (import.meta.env.VITE_APP_SENTRY_ENABLED === 'true') {
Expand Down Expand Up @@ -47,7 +46,6 @@ const oidcConfig = {
post_logout_redirect_uri: `${import.meta.env.VITE_APP_AUTH_REDIRECT_URI}/login`,
userStore: new WebStorageStateStore({ store: window.localStorage }),
scope: 'openid profile email',
onSigninCallback: () => signInCallBack(store),
};

const instance = createInstance({
Expand Down
3 changes: 3 additions & 0 deletions src/services/auth/signInCallBack.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const signInCallBack = async (dispatch, code, state, verificationToken) => {
localStorage.setItem('loginError', JSON.stringify(error?.response?.data ?? 'Connexion refusée'));
localStorage.removeItem('user');
dispatch({ type: 'LOGIN_FAILURE' });
if (error.response?.data?.logoutUrl) {
return { success: false, logoutUrl: error.response.data.logoutUrl };
}
return { success: false };
}
};
Expand Down

0 comments on commit b6f04d1

Please sign in to comment.