init
This commit is contained in:
@@ -1,42 +1,32 @@
|
||||
import React from 'react';
|
||||
import ReactDom from 'react-dom';
|
||||
import React from "react";
|
||||
import ReactDom from "react-dom";
|
||||
|
||||
import App from './app';
|
||||
import { keycloak } from './__data__/const';
|
||||
import App from "./app";
|
||||
import { keycloak } from "./__data__/kc";
|
||||
import { createStore } from "./__data__/store";
|
||||
|
||||
export default () => <App/>;
|
||||
export default (props) => <App {...props} />;
|
||||
|
||||
const start = async () => {
|
||||
// onLoad: 'check-sso',
|
||||
// silentCheckSsoRedirectUri: `${location.origin}/silent-check-sso.html`
|
||||
export const mount = async (Сomponent) => {
|
||||
let user = null;
|
||||
try {
|
||||
const authenticated = await keycloak.init({ onLoad: 'check-sso' }) // 'login-required' });
|
||||
console.log(`User is ${authenticated ? 'authenticated' : 'not authenticated'}`);
|
||||
await keycloak.init({ onLoad: "login-required" }); // 'login-required' });
|
||||
user = { ...(await keycloak.loadUserInfo()), ...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 });
|
||||
|
||||
start();
|
||||
ReactDom.render(<Сomponent store={store} />, document.getElementById("app"));
|
||||
|
||||
export const mount = (Сomponent) => {
|
||||
ReactDom.render(
|
||||
<Сomponent/>,
|
||||
document.getElementById('app')
|
||||
);
|
||||
|
||||
if(module.hot) {
|
||||
module.hot.accept('./app', ()=> {
|
||||
ReactDom.render(
|
||||
<App/>,
|
||||
document.getElementById('app')
|
||||
);
|
||||
})
|
||||
}
|
||||
if (module.hot) {
|
||||
module.hot.accept("./app", () => {
|
||||
ReactDom.render(<App store={store} />, document.getElementById("app"));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const unmount = () => {
|
||||
ReactDom.unmountComponentAtNode(document.getElementById('app'));
|
||||
ReactDom.unmountComponentAtNode(document.getElementById("app"));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user