Skip to content

Commit

Permalink
Fixes the race condition between get_env_config and authenticate requ…
Browse files Browse the repository at this point in the history
…est.

fixes mathworks#37
  • Loading branch information
krisctl authored and prabhakk-mw committed Sep 18, 2024
1 parent 08b1c45 commit 0001264
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions gui/src/components/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,18 @@ function App () {
}, [loadUrl]);

useEffect(() => {
const queryParams = parseQueryParams(window.location);
const token = queryParams.get(MWI_AUTH_TOKEN_NAME_FOR_HTTP);

if (token) {
dispatch(updateAuthStatus(token));
// Send authenticate request only after env config is fetched,
// fixes https://github.com/mathworks/matlab-proxy/issues/37
if (hasFetchedEnvConfig) {
const queryParams = parseQueryParams(window.location);
const token = queryParams.get(MWI_AUTH_TOKEN_NAME_FOR_HTTP);

if (token) {
dispatch(updateAuthStatus(token));
}
window.history.replaceState(null, '', `${baseUrl}index.html`);
}
window.history.replaceState(null, '', `${baseUrl}index.html`);
}, [dispatch, baseUrl]);
}, [dispatch, baseUrl, hasFetchedEnvConfig]);

// Display one of:
// * Confirmation
Expand Down

0 comments on commit 0001264

Please sign in to comment.