File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
met-web/src/services/userService Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -18,22 +18,34 @@ import { USER_ROLES } from 'services/userService/constants';
1818import { getBaseUrl } from 'utils/helpers' ;
1919
2020const KeycloakData = _kc ;
21+
22+ let isInitializing = false ;
23+ let isInitialized = false ;
24+
2125/**
2226 * Initializes Keycloak instance.
2327 */
2428const initKeycloak = async ( dispatch : Dispatch < AnyAction > ) => {
2529 console . log ( '[Keycloak] Starting initialization' ) ;
26- if ( KeycloakData . authenticated === true || KeycloakData . authenticated === false ) {
27- console . log ( '[Keycloak] Already initialized' ) ;
30+
31+ if ( isInitializing || isInitialized ) {
32+ console . log ( '[Keycloak] Already initialized or initializing' ) ;
2833 return ;
2934 }
35+
36+ isInitializing = true ;
3037 try {
3138 const authenticated = await KeycloakData . init ( {
3239 onLoad : 'check-sso' ,
3340 silentCheckSsoRedirectUri : window . location . origin + '/silent-check-sso.html' ,
3441 pkceMethod : 'S256' ,
3542 checkLoginIframe : false ,
3643 } ) ;
44+
45+ isInitialized = true ;
46+
47+ console . log ( '[Keycloak] Init completed, authenticated:' , authenticated ) ;
48+
3749 if ( ! authenticated ) {
3850 console . warn ( 'not authenticated!' ) ;
3951 dispatch ( userAuthentication ( authenticated ) ) ;
You can’t perform that action at this time.
0 commit comments