twik a bit

This commit is contained in:
Primakov Alexandr Alexandrovich 2025-01-07 16:57:37 +03:00
parent 6b07fef62f
commit 55d23f1e47
3 changed files with 1037 additions and 1937 deletions

2955
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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 });