Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@gridsuite/commons-ui": "0.100.0",
"@gridsuite/commons-ui": "0.101.0",
"@hookform/resolvers": "^4.0.0",
"@mui/icons-material": "^5.16.14",
"@mui/lab": "5.0.0-alpha.175",
Expand Down
3 changes: 1 addition & 2 deletions src/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from 'react-router';
import { useDispatch, useSelector } from 'react-redux';
import { AppState } from '../redux/reducer';
import { AppsMetadataSrv, UserAdminSrv } from '../services';
import { AppsMetadataSrv } from '../services';
import type { App } from '../components/App';
import { updateUserManagerDestructured } from '../redux/actions';
import { getErrorMessage } from '../utils/error';
Expand Down Expand Up @@ -78,7 +78,6 @@ const AppAuthStateWithRouterLayer: FunctionComponent<PropsWithChildren<{ layout:
dispatch,
initialMatchSilentRenewCallbackUrl != null,
AppsMetadataSrv.fetchIdpSettings,
UserAdminSrv.fetchValidateUser,
initialMatchSignInCallbackUrl != null
)) ?? null,
null
Expand Down
24 changes: 0 additions & 24 deletions src/services/user-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { User } from 'oidc-client';
import { backendFetch, backendFetchJson, getRestBase } from '../utils/api-rest';
import { extractUserSub, getToken } from '../utils/api';
import { UUID } from 'crypto';

const USER_ADMIN_URL = `${getRestBase()}/user-admin/v1`;

/*
* fetchValidateUser is call from commons-ui AuthServices to validate user infos before setting state.user!
*/
export function fetchValidateUser(user: User): Promise<boolean> {
return extractUserSub(user)
.then((sub) => {
console.debug(`Fetching access for user "${sub}"...`);
return backendFetch(`${USER_ADMIN_URL}/users/${sub}`, { method: 'head' }, getToken(user) ?? undefined);
})
.then((response: Response) => {
//if the response is ok, the responseCode will be either 200 or 204 otherwise it's an HTTP error and it will be caught
return response.status === 200;
})
.catch((error) => {
if (error.status === 403) {
return false;
} else {
throw error;
}
});
}

export type UserInfos = {
sub: string;
profileName?: string;
Expand Down
Loading