Skip to content
Open
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
7 changes: 0 additions & 7 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
fetchConfigParameter,
fetchConfigParameters,
fetchIdpSettings,
fetchValidateUser,
} from '../utils/rest-api';
import { APP_NAME, COMMON_APP_NAME, PARAM_LANGUAGE, PARAM_THEME } from '../utils/config-params';
import { getComputedLanguage } from '../utils/language';
Expand Down Expand Up @@ -117,13 +116,11 @@ const App: FunctionComponent = () => {
dispatch,
initialMatchSilentRenewCallbackUrl != null,
fetchIdpSettings,
fetchValidateUser,
initialMatchSigninCallbackUrl != null
)
: initializeAuthenticationDev(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
validateUserDev,
initialMatchSigninCallbackUrl != null
);
setUserManager({
Expand Down Expand Up @@ -211,7 +208,3 @@ const App: FunctionComponent = () => {
);
};
export default App;

function validateUserDev(): Promise<boolean> {
return new Promise((resolve) => window.setTimeout(() => resolve(true), 500));
}
25 changes: 0 additions & 25 deletions src/utils/rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { Env, GsLangUser, GsTheme } from '@gridsuite/commons-ui';
import { User } from 'oidc-client';
import { APP_NAME, getAppName, PARAM_LANGUAGE, PARAM_THEME } from './config-params';
import { store } from '../redux/store';
import ReconnectingWebSocket, { Event } from 'reconnecting-websocket';
Expand Down Expand Up @@ -114,30 +113,6 @@ export function backendFetchJson(url: Url, init?: InitRequest, token?: Token): P
return backendFetch(url, init, token).then((safeResponse: Response) => safeResponse.json());
}

export function fetchValidateUser(user: User): Promise<boolean> {
const sub = user?.profile?.sub;
if (!sub) {
return Promise.reject(new Error(`Error : Fetching access for missing user.profile.sub : ${user}`));
}

console.info(`Fetching access for user...`);
const CheckAccessUrl = `${PREFIX_USER_ADMIN_SERVER_QUERIES}/v1/users/${sub}`;
console.debug(CheckAccessUrl);

return backendFetch(CheckAccessUrl, { method: 'head' }, user?.id_token)
.then((response: Response) => {
//if the response is ok, the responseCode will be either 200 or 204 otherwise it's a Http error and it will be caught
return response.status === 200;
})
.catch((error) => {
if (error.status === 403) {
return false;
} else {
throw error;
}
});
}

export type EnvJson = Env & typeof import('../../public/env.json');

function fetchEnv(): Promise<EnvJson> {
Expand Down
Loading