improve: add production stage
This commit is contained in:
19
src/components/KeycloakCallbacks/Callback.js
Normal file
19
src/components/KeycloakCallbacks/Callback.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import React, {useContext, useEffect} from "react";
|
||||
import { UserManager } from "oidc-client-ts";
|
||||
import {ConfigContext} from "../../ConfigProvider";
|
||||
|
||||
|
||||
const Callback = () => {
|
||||
const config = useContext(ConfigContext).config;
|
||||
useEffect(() => {
|
||||
const userManager = new UserManager(config.OIDC_CONFIG);
|
||||
userManager.signinRedirectCallback()
|
||||
.then(() => {
|
||||
window.location.href = "/";
|
||||
});
|
||||
}, []);
|
||||
|
||||
return <div>Logging in...</div>;
|
||||
};
|
||||
|
||||
export default Callback;
|
||||
24
src/components/KeycloakCallbacks/PopupCallback.js
Normal file
24
src/components/KeycloakCallbacks/PopupCallback.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import React, { useEffect, useContext } from "react";
|
||||
import { UserManager } from "oidc-client-ts";
|
||||
import {ConfigContext} from "../../ConfigProvider";
|
||||
|
||||
|
||||
const PopupCallback = () => {
|
||||
const { config } = useContext(ConfigContext);
|
||||
|
||||
useEffect(() => {
|
||||
const userManager = new UserManager(config.OIDC_CONFIG);
|
||||
userManager.signinPopupCallback()
|
||||
.then(() => {
|
||||
window.close();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Popup callback error:", err);
|
||||
window.close();
|
||||
});
|
||||
}, [config]);
|
||||
|
||||
return <div>Processing...</div>;
|
||||
};
|
||||
|
||||
export default PopupCallback;
|
||||
21
src/components/KeycloakCallbacks/SilentCallback.js
Normal file
21
src/components/KeycloakCallbacks/SilentCallback.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import React, { useEffect, useContext } from "react";
|
||||
import { UserManager } from "oidc-client-ts";
|
||||
import { ConfigContext } from "../../ConfigProvider";
|
||||
|
||||
const SilentCallback = () => {
|
||||
const { config } = useContext(ConfigContext);
|
||||
|
||||
useEffect(() => {
|
||||
const userManager = new UserManager(config.OIDC_CONFIG);
|
||||
userManager.signinSilentCallback()
|
||||
.then(() => {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Silent callback error:", err);
|
||||
});
|
||||
}, [config]);
|
||||
|
||||
return <div>Renew...</div>;
|
||||
};
|
||||
|
||||
export default SilentCallback;
|
||||
Reference in New Issue
Block a user