Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Jul 3, 2024
1 parent aa48c98 commit 3937068
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
32 changes: 16 additions & 16 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,23 @@ const App: FunctionComponent = () => {
console.debug(
`auth dev mode: ${process.env.REACT_APP_USE_AUTHENTICATION}`
);
const initAuth =
process.env.REACT_APP_USE_AUTHENTICATION === 'true'
? initializeAuthenticationProd(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
fetchIdpSettings,
fetchValidateUser,
initialMatchSigninCallbackUrl != null
)
: initializeAuthenticationDev(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
validateUserDev,
initialMatchSigninCallbackUrl != null
);
setUserManager({
instance:
(await (process.env.REACT_APP_USE_AUTHENTICATION ===
'true'
? initializeAuthenticationProd(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
fetchIdpSettings,
fetchValidateUser,
initialMatchSigninCallbackUrl != null
)
: initializeAuthenticationDev(
dispatch,
initialMatchSilentRenewCallbackUrl != null,
validateUserDev,
initialMatchSigninCallbackUrl != null
))) ?? null,
instance: (await initAuth) ?? null,
error: null,
});
} catch (error) {
Expand Down
13 changes: 3 additions & 10 deletions src/utils/rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Env, IdpSettings } from '@gridsuite/commons-ui';
import {
APP_NAME,
getAppName,
Expand Down Expand Up @@ -164,21 +165,13 @@ export function fetchValidateUser(user: User): Promise<boolean> {
});
}

export type EnvJson = typeof import('../../public/env.json') & {
// https://github.com/gridsuite/deployment/blob/main/docker-compose/env.json
// https://github.com/gridsuite/deployment/blob/main/k8s/live/azure-dev/env.json
// https://github.com/gridsuite/deployment/blob/main/k8s/live/azure-integ/env.json
// https://github.com/gridsuite/deployment/blob/main/k8s/live/local/env.json
appsMetadataServerUrl?: Url;
mapBoxToken?: string;
//[key: string]: string;
};
export type EnvJson = Env & typeof import('../../public/env.json');

function fetchEnv(): Promise<EnvJson> {
return fetch('env.json').then((res: Response) => res.json());
}

export function fetchIdpSettings() {
export function fetchIdpSettings(): Promise<IdpSettings> {
return fetch('idpSettings.json').then((res) => res.json());
}

Expand Down

0 comments on commit 3937068

Please sign in to comment.