Skip to content

Commit

Permalink
Fix: renew token only if user is logged in (#1036)
Browse files Browse the repository at this point in the history
* renew token if user loged

* fix test
  • Loading branch information
PierreVasseur authored Oct 15, 2024
1 parent dfd5af9 commit 5f9b4a9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/packages/application/router/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('RBACLink Component', () => {
);

screen.getByText('Child Component');
screen.getByText('TestApp - Front 1.0.0 - API 2.0.0');
screen.getByText('TestApp - IHM 1.0.0 - API 2.0.0');
screen.getByAltText('application logo');
});

Expand Down
2 changes: 1 addition & 1 deletion src/packages/application/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const RBACLink = ({ children }: PropsWithChildren<unknown>) => {
properties: { authorizationHost },
} = useAppContext();
const { version } = useAppContext();
const footer = `${getEnvVar('NAME')} - Front ${getEnvVar(
const footer = `${getEnvVar('NAME')} - IHM ${getEnvVar(
'VERSION',
)} - API ${version}`;

Expand Down
8 changes: 4 additions & 4 deletions src/packages/auth/open-id-connect-auth/use-oidc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const LoginOidcComponent = ({
const { isUserLoggedIn, login, oidcTokens } = useOidc({
assertUserLoggedIn: false,
});
const { renewTokens } = useOidc({ assertUserLoggedIn: false });
const { renewTokens } = useOidc({ assertUserLoggedIn: true });
const [userInformationLoaded, setUserInformationLoaded] = useState(false);

if (!isUserLoggedIn) {
Expand All @@ -35,10 +35,10 @@ const LoginOidcComponent = ({
saveUserProps({ roles, stamp });
setUserInformationLoaded(true);
});
setInterval(() => {
renewTokens();
}, 120000);
}
setInterval(() => {
renewTokens();
}, 120000);
}, []);

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type ImportMetaEnv = {
VITE_OIDC_CLIENT_ID: string
VITE_CONCEPTS_DOCUMENTATION: string
VITE_OPERATIONS_DOCUMENTATION: string
VITE_DEV_TOOLS_ENABLED: boolean
VITE_DEV_TOOLS_ENABLED: string
VITE_INSEE: string
VITE_NAME: string
VITE_VERSION: string
VITE_INSEE: boolean
BASE_URL: string
MODE: string
DEV: boolean
Expand Down

0 comments on commit 5f9b4a9

Please sign in to comment.