Skip to content

Commit

Permalink
Moving on with account configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Apr 20, 2023
1 parent e936877 commit 5dd64cd
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"i18nifty": "^1.3.26",
"jwt-decode": "^3.1.2",
"keycloak-js": "^21.0.2",
"keycloakify": "7.9.0-rc.0",
"keycloakify": "^7.9.2",
"memoizee": "^0.4.14",
"moment": "^2.29.1",
"path": "^0.12.7",
Expand Down
20 changes: 12 additions & 8 deletions src/core/adapter/oidc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ export async function createOidc(params: {
"checkLoginIframe": false,
"adapter": createKeycloakAdapter({
"transformUrlBeforeRedirect": url =>
[url].map(transformUrlBeforeRedirect).map(
url =>
addParamToUrl({
url,
"name": "ui_locales",
"value": getUiLocales()
}).newUrl
)[0],
// prettier-ignore
[url]
.map(transformUrlBeforeRedirect)
.map(
url =>
addParamToUrl({
url,
"name": "ui_locales",
"value": getUiLocales()
}).newUrl
)
[0],
keycloakInstance,
"getRedirectMethod": () => redirectMethod
})
Expand Down
46 changes: 33 additions & 13 deletions src/core/usecases/userAccountManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ export const thunks = {
"passwordResetUrlWithoutLangParam":
keycloakParams === undefined
? undefined
: [
keycloakParams.url.replace(/\/$/, ""),
"realms",
keycloakParams.realm,
"account",
"password"
].join("/"),
: addParamToUrl({
"url": [
keycloakParams.url.replace(/\/$/, ""),
"realms",
keycloakParams.realm,
"account",
"password"
].join("/"),
"name": "referrer",
"value": keycloakParams.clientId
}).newUrl,
allOrganizations
})
);
Expand Down Expand Up @@ -195,13 +199,29 @@ export const thunks = {

assert(state.passwordResetUrlWithoutLangParam !== undefined);

const { newUrl } = addParamToUrl({
"url": state.passwordResetUrlWithoutLangParam,
"name": "kc_locale",
"value": lang
});
let url = state.passwordResetUrlWithoutLangParam;

return newUrl;
{
const { newUrl } = addParamToUrl({
url,
"name": "referrer_uri",
"value": window.location.href
});

url = newUrl;
}

{
const { newUrl } = addParamToUrl({
url,
"name": "kc_locale",
"value": lang
});

url = newUrl;
}

return url;
}
};

Expand Down
39 changes: 13 additions & 26 deletions src/keycloak-theme/account/pages/Password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { PageProps } from "keycloakify/account/pages/PageProps";
import { useGetClassName } from "keycloakify/account/lib/useGetClassName";
import type { KcContext } from "../kcContext";
import type { I18n } from "../i18n";
import { Input } from "@codegouvfr/react-dsfr/Input";

export default function LogoutConfirm(
props: PageProps<Extract<KcContext, { pageId: "password.ftl" }>, I18n>
Expand All @@ -23,14 +24,8 @@ export default function LogoutConfirm(

return (
<Template {...{ kcContext, i18n, doUseDefaultCss, classes }} active="password">
<div className="row">
<div className="col-md-10">
<h2>{msg("changePasswordHtmlTitle")}</h2>
</div>
<div className="col-md-2 subtitle">
<span className="subtitle">{msg("allFieldsRequired")}</span>
</div>
</div>
<h2>{msg("changePasswordHtmlTitle")}</h2>
<p>{msg("allFieldsRequired")}</p>

<form action={url.passwordUrl} className="form-horizontal" method="post">
<input
Expand All @@ -44,24 +39,16 @@ export default function LogoutConfirm(
/>

{password.passwordSet && (
<div className="form-group">
<div className="col-sm-2 col-md-2">
<label htmlFor="password" className="control-label">
{msg("password")}
</label>
</div>

<div className="col-sm-10 col-md-10">
<input
type="password"
className="form-control"
id="password"
name="password"
autoFocus
autoComplete="current-password"
/>
</div>
</div>
<Input
label={msg("password")}
nativeInputProps={{
"type": "password",
"id": "password",
"name": "password",
"autoFocus": true,
"autoComplete": "current-password"
}}
/>
)}

<input
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10093,10 +10093,10 @@ keycloak-js@^21.0.2:
base64-js "^1.5.1"
js-sha256 "^0.9.0"

keycloakify@7.9.0-rc.0:
version "7.9.0-rc.0"
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-7.9.0-rc.0.tgz#60fce296a6e0b7cdf38ffe39fa6ef4914885a751"
integrity sha512-pTLDGhknPgBOYBLszrIsMRYj0D9KKM43RjXfQJpjP6oaSQCaMGU9qfqRFIkt5GefOISDLv5GpP3GC3sz9vR/Kg==
keycloakify@^7.9.2:
version "7.9.2"
resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-7.9.2.tgz#bf64ce616b6b955d0d2ab2f0c697d8c393a599eb"
integrity sha512-yARvJTsIjQCdT3GA3vh1ejcqlF9U8RYZ+wpEI8JNj0CI0viok/OxbLsI6fmeZL0n3PKYpCwMRj7uafdFOekrSQ==
dependencies:
"@octokit/rest" "^18.12.0"
"@types/yazl" "^2.4.2"
Expand Down

0 comments on commit 5dd64cd

Please sign in to comment.