Skip to content

Commit 6d39ac7

Browse files
Remove old authentication flag and update fn call (#447)
1 parent dc97bef commit 6d39ac7

File tree

4 files changed

+27
-55
lines changed

4 files changed

+27
-55
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@emotion/react": "^11.11.4",
99
"@emotion/styled": "^11.11.5",
10-
"@gridsuite/commons-ui": "0.61.1",
10+
"@gridsuite/commons-ui": "0.62.0",
1111
"@hookform/resolvers": "^3.3.4",
1212
"@mui/icons-material": "^5.15.14",
1313
"@mui/lab": "5.0.0-alpha.169",

src/components/app.jsx

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,33 @@
66
*/
77

88
import React, { useCallback, useEffect, useState } from 'react';
9-
109
import { useDispatch, useSelector } from 'react-redux';
11-
1210
import {
1311
Navigate,
1412
Route,
1513
Routes,
16-
useNavigate,
1714
useLocation,
15+
useMatch,
16+
useNavigate,
1817
} from 'react-router-dom';
19-
2018
import {
2119
selectComputedLanguage,
2220
selectLanguage,
2321
selectTheme,
2422
} from '../redux/actions';
25-
2623
import {
2724
AuthenticationRouter,
2825
CardErrorBoundary,
2926
getPreLoginPath,
3027
initializeAuthenticationProd,
28+
useSnackMessage,
3129
} from '@gridsuite/commons-ui';
32-
33-
import { useMatch } from 'react-router-dom';
3430
import { FormattedMessage } from 'react-intl';
35-
3631
import {
3732
connectNotificationsWsUpdateConfig,
38-
fetchAuthorizationCodeFlowFeatureFlag,
3933
fetchConfigParameter,
4034
fetchConfigParameters,
35+
fetchIdpSettings,
4136
fetchValidateUser,
4237
} from '../utils/rest-api';
4338
import {
@@ -47,7 +42,6 @@ import {
4742
PARAM_THEME,
4843
} from '../utils/config-params';
4944
import { getComputedLanguage } from '../utils/language';
50-
import { useSnackMessage } from '@gridsuite/commons-ui';
5145
import AppTopBar from './app-top-bar';
5246
import Grid from '@mui/material/Grid';
5347
import TreeViewsContainer from './tree-views-container';
@@ -149,23 +143,23 @@ const App = () => {
149143
);
150144

151145
useEffect(() => {
152-
fetchAuthorizationCodeFlowFeatureFlag()
153-
.then((authorizationCodeFlowEnabled) => {
154-
return initializeAuthenticationProd(
155-
dispatch,
156-
initialMatchSilentRenewCallbackUrl != null,
157-
fetch('idpSettings.json'),
158-
fetchValidateUser,
159-
authorizationCodeFlowEnabled,
160-
initialMatchSigninCallbackUrl != null
161-
);
162-
})
163-
.then((userManager) => {
164-
setUserManager({ instance: userManager, error: null });
165-
})
166-
.catch(function (error) {
146+
// need subfunction when async as suggested by rule react-hooks/exhaustive-deps
147+
(async function initializeAuthentication() {
148+
try {
149+
setUserManager({
150+
instance: await initializeAuthenticationProd(
151+
dispatch,
152+
initialMatchSilentRenewCallbackUrl != null,
153+
fetchIdpSettings,
154+
fetchValidateUser,
155+
initialMatchSigninCallbackUrl != null
156+
),
157+
error: null,
158+
});
159+
} catch (error) {
167160
setUserManager({ instance: null, error: error.message });
168-
});
161+
}
162+
})();
169163
// Note: initialMatchSilentRenewCallbackUrl and dispatch don't change
170164
}, [
171165
initialMatchSilentRenewCallbackUrl,

src/utils/rest-api.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,30 +173,8 @@ export function fetchValidateUser(user) {
173173
});
174174
}
175175

176-
export function fetchAuthorizationCodeFlowFeatureFlag() {
177-
console.info(`Fetching authorization code flow feature flag...`);
178-
return fetchEnv()
179-
.then((res) =>
180-
fetch(res.appsMetadataServerUrl + '/authentication.json')
181-
)
182-
.then((res) => res.json())
183-
.then((res) => {
184-
console.log(
185-
`Authorization code flow is ${
186-
res.authorizationCodeFlowFeatureFlag
187-
? 'enabled'
188-
: 'disabled'
189-
}`
190-
);
191-
return res.authorizationCodeFlowFeatureFlag;
192-
})
193-
.catch((error) => {
194-
console.error(error);
195-
console.warn(
196-
`Something wrong happened when retrieving authentication.json: authorization code flow will be disabled`
197-
);
198-
return false;
199-
});
176+
export function fetchIdpSettings() {
177+
return fetch('idpSettings.json').then((res) => res.json());
200178
}
201179

202180
export function fetchVersion() {

0 commit comments

Comments
 (0)