Skip to content

Commit

Permalink
Feat: stop using local storage for token (#1044)
Browse files Browse the repository at this point in the history
* delete useless functions

* file deleted by mistake
  • Loading branch information
PierreVasseur authored Oct 18, 2024
1 parent b3f279b commit 668accb
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 121 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions src/packages/application/router/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useLocation } from 'react-router-dom';
import { Mock, vi } from 'vitest';
import { RBACLink } from '.';
import { useOidc } from '../../auth/create-oidc';
import { removeToken } from '../../auth/open-id-connect-auth/token-utils';
import D from '../../i18n';
import configureStore from '../../redux/configure-store';
import { renderWithAppContext } from '../../tests-utils/render';
Expand All @@ -26,10 +25,6 @@ vi.mock('../../utils/env', () => ({
getEnvVar: (key: string) => (key === 'NAME' ? 'TestApp' : '1.0.0'),
}));

vi.mock('../../auth/open-id-connect-auth/token-utils', () => ({
removeToken: vi.fn(),
}));

const store = configureStore({
app: {
auth: {
Expand Down Expand Up @@ -81,7 +76,6 @@ describe('RBACLink Component', () => {
});
fireEvent.click(logoutButton);

expect(removeToken).toHaveBeenCalled();
expect(logout).toHaveBeenCalled();
});
});
2 changes: 0 additions & 2 deletions src/packages/application/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { PropsWithChildren } from 'react';
import 'react-app-polyfill/stable';
import bauhausLogo from '../../../img/logo_noir.svg';
import Auth from '../../auth/components/auth';
import { removeToken } from '../../auth/open-id-connect-auth/token-utils';
import { ADMIN } from '../../auth/roles';
import D from '../../i18n';
import { getEnvVar } from '../../utils/env';
Expand All @@ -15,7 +14,6 @@ export const RBACLink = ({ children }: PropsWithChildren<unknown>) => {
const { isUserLoggedIn, logout } = useOidc();

const logoutAndRemoveFromStorage = () => {
removeToken();
if (isUserLoggedIn) {
logout({
redirectTo: 'specific url',
Expand Down
81 changes: 0 additions & 81 deletions src/packages/auth/open-id-connect-auth/token-utils.spec.jsx

This file was deleted.

26 changes: 0 additions & 26 deletions src/packages/auth/open-id-connect-auth/token-utils.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/packages/auth/open-id-connect-auth/use-oidc.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { connect } from 'react-redux';
import { saveUserProps } from '../../redux/users';
import { useOidc } from '../create-oidc';
import { storeToken } from './token-utils';
import { useEffect, useState } from 'react';
import { UsersApi } from '../../sdk/users-api';

Expand Down Expand Up @@ -34,7 +33,6 @@ const LoggedInWrapper = ({
const [userInformationLoaded, setUserInformationLoaded] = useState(false);

useEffect(() => {
storeToken(oidcTokens?.accessToken);
UsersApi.getStamp().then(({ stamp }: { stamp: string }) => {
const roles = (oidcTokens?.decodedIdToken.realm_access as any).roles;
saveUserProps({ roles, stamp });
Expand All @@ -45,10 +43,6 @@ const LoggedInWrapper = ({
}, 120000);
}, []);

useEffect(() => {
storeToken(oidcTokens?.accessToken);
}, [oidcTokens]);

if (!userInformationLoaded) {
return null;
}
Expand Down

0 comments on commit 668accb

Please sign in to comment.