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({
|
export const keycloak = new Keycloak({
|
||||||
url: KC_URL,
|
url: KC_URL,
|
||||||
realm: KC_REALM,
|
realm: KC_REALM,
|
||||||
clientId: KC_CLIENT_ID,
|
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')) => {
|
export const mount = async (Component, element = document.getElementById('app')) => {
|
||||||
let user = null;
|
let user = null;
|
||||||
try {
|
try {
|
||||||
await keycloak.init({ onLoad: "check-sso" }); // "login-required" });
|
await keycloak.init({ onLoad: 'check-sso' }) // 'login-required' });
|
||||||
user = { ...(await keycloak.loadUserInfo()), ...keycloak.tokenParsed };
|
|
||||||
|
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) {
|
} catch (error) {
|
||||||
console.error("Failed to initialize adapter:", error);
|
console.error('Failed to initialize adapter:', error)
|
||||||
keycloak.login();
|
// keycloak.login()
|
||||||
}
|
}
|
||||||
const store = createStore({ user });
|
const store = createStore({ user });
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user