twik a bit
This commit is contained in:
parent
6b07fef62f
commit
55d23f1e47
2955
package-lock.json
generated
2955
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
||||
import Keycloak from 'keycloak-js';
|
||||
import Keycloak from 'keycloak-js'
|
||||
|
||||
export const keycloak = new Keycloak({
|
||||
url: KC_URL,
|
||||
realm: KC_REALM,
|
||||
clientId: KC_CLIENT_ID,
|
||||
});
|
||||
|
||||
(window as any).kc = keycloak
|
@ -17,11 +17,18 @@ let rootElement: ReactDOM.Root
|
||||
export const mount = async (Component, element = document.getElementById('app')) => {
|
||||
let user = null;
|
||||
try {
|
||||
await keycloak.init({ onLoad: "check-sso" }); // "login-required" });
|
||||
user = { ...(await keycloak.loadUserInfo()), ...keycloak.tokenParsed };
|
||||
await keycloak.init({ onLoad: 'check-sso' }) // 'login-required' });
|
||||
|
||||
const userInfo = await keycloak.loadUserInfo()
|
||||
|
||||
if (userInfo && keycloak.tokenParsed) {
|
||||
user = { ...userInfo, ...keycloak.tokenParsed }
|
||||
} else {
|
||||
console.error('No userInfo or tokenParsed', userInfo, keycloak.tokenParsed)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize adapter:", error);
|
||||
keycloak.login();
|
||||
console.error('Failed to initialize adapter:', error)
|
||||
// keycloak.login()
|
||||
}
|
||||
const store = createStore({ user });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user