Fix redirect back from account page
This commit is contained in:
parent
6ebae032f4
commit
c30e0600fc
|
@ -37,7 +37,7 @@
|
||||||
"evt": "^2.4.15",
|
"evt": "^2.4.15",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"keycloak-js": "^21.0.1",
|
"keycloak-js": "^21.0.1",
|
||||||
"keycloakify": "^7.9.2",
|
"keycloakify": "^7.9.4",
|
||||||
"powerhooks": "^0.26.8",
|
"powerhooks": "^0.26.8",
|
||||||
"react": "18.1.0",
|
"react": "18.1.0",
|
||||||
"react-dom": "18.1.0",
|
"react-dom": "18.1.0",
|
||||||
|
|
|
@ -51,13 +51,20 @@ function ContextualizedApp() {
|
||||||
value: "en"
|
value: "en"
|
||||||
}).newUrl;
|
}).newUrl;
|
||||||
|
|
||||||
// Enable to redirect to the app from the account page we'll get kcContext.url.referrerURI
|
// Enable to redirect to the app from the account page we'll get the referrer_uri under kcContext.referrer.url
|
||||||
|
// It's useful to avoid hard coding the app url in the keycloak config
|
||||||
accountUrl = addParamToUrl({
|
accountUrl = addParamToUrl({
|
||||||
url: accountUrl,
|
url: accountUrl,
|
||||||
name: "referrer",
|
name: "referrer",
|
||||||
value: keycloakClient
|
value: keycloakClient
|
||||||
}).newUrl;
|
}).newUrl;
|
||||||
|
|
||||||
|
accountUrl = addParamToUrl({
|
||||||
|
url: accountUrl,
|
||||||
|
name: "referrer_uri",
|
||||||
|
value: window.location.href
|
||||||
|
}).newUrl;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<header className="App-header">
|
<header className="App-header">
|
||||||
|
@ -66,7 +73,7 @@ function ContextualizedApp() {
|
||||||
<>
|
<>
|
||||||
<h1>You are authenticated !</h1>
|
<h1>You are authenticated !</h1>
|
||||||
{/* On older Keycloak version its /auth/realms instead of /realms */}
|
{/* On older Keycloak version its /auth/realms instead of /realms */}
|
||||||
<a href={accountUrl} target="_blank" rel="noreferrer">Link to your Keycloak account</a>
|
<a href={accountUrl}>Link to your Keycloak account</a>
|
||||||
<pre style={{ textAlign: "left" }}>{JSON.stringify(jwt_decode(oidcClient.getAccessToken()), null, 2)}</pre>
|
<pre style={{ textAlign: "left" }}>{JSON.stringify(jwt_decode(oidcClient.getAccessToken()), null, 2)}</pre>
|
||||||
<button onClick={() => oidcClient.logout({ redirectTo: "home" })}>Logout</button>
|
<button onClick={() => oidcClient.logout({ redirectTo: "home" })}>Logout</button>
|
||||||
</>
|
</>
|
||||||
|
@ -78,7 +85,7 @@ function ContextualizedApp() {
|
||||||
<img src={logo} className="App-logo" alt="logo" />
|
<img src={logo} className="App-logo" alt="logo" />
|
||||||
<img src={myimg} alt="test_image" />
|
<img src={myimg} alt="test_image" />
|
||||||
<p style={{ "fontFamily": '"Work Sans"' }}>Hello world</p>
|
<p style={{ "fontFamily": '"Work Sans"' }}>Hello world</p>
|
||||||
<p>Check out all keycloak pages in the <a href="https://storybook.keycloakify.dev">Storybook</a>!</p>
|
<p>Check out all keycloak pages in the <a href="https://storybook.keycloakify.dev/storybook">Storybook</a>!</p>
|
||||||
<p>Once you've identified the ones you want to customize run <code>npx eject-keycloak-page</code></p>
|
<p>Once you've identified the ones you want to customize run <code>npx eject-keycloak-page</code></p>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{referrer?.url !== undefined && (
|
{referrer?.url && (
|
||||||
<li>
|
<li>
|
||||||
<a href={referrer.url} id="referrer">
|
<a href={referrer.url} id="referrer">
|
||||||
{msg("backTo", referrer.name)}
|
{msg("backTo", referrer.name)}
|
||||||
|
|
|
@ -9697,10 +9697,10 @@ keycloak-js@^21.0.1:
|
||||||
base64-js "^1.5.1"
|
base64-js "^1.5.1"
|
||||||
js-sha256 "^0.9.0"
|
js-sha256 "^0.9.0"
|
||||||
|
|
||||||
keycloakify@^7.9.2:
|
keycloakify@^7.9.4:
|
||||||
version "7.9.2"
|
version "7.9.4"
|
||||||
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-7.9.2.tgz#bf64ce616b6b955d0d2ab2f0c697d8c393a599eb"
|
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-7.9.4.tgz#c458330ada1136ee80e627234f4536a101d77c7e"
|
||||||
integrity sha512-yARvJTsIjQCdT3GA3vh1ejcqlF9U8RYZ+wpEI8JNj0CI0viok/OxbLsI6fmeZL0n3PKYpCwMRj7uafdFOekrSQ==
|
integrity sha512-XoCEaSsHT0Ynp49KgK6qUSllEbpOzP1e0E2CpCcm32k18GA8w/oJokADnH5O1bf60jt5vUKW0lxIqvnPSCY/2Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@octokit/rest" "^18.12.0"
|
"@octokit/rest" "^18.12.0"
|
||||||
"@types/yazl" "^2.4.2"
|
"@types/yazl" "^2.4.2"
|
||||||
|
|
Loading…
Reference in a new issue