@@ -4,6 +4,7 @@ import type { PageProps } from "keycloakify/account/pages/PageProps";
4
4
import { clsx } from "keycloakify/tools/clsx" ;
5
5
import type { KcContext } from "../KcContext" ;
6
6
import type { I18n } from "../i18n" ;
7
+ import { useOidc } from "../oidc" ;
7
8
8
9
export default function Account ( props : PageProps < Extract < KcContext , { pageId : "account.ftl" } > , I18n > ) {
9
10
const { kcContext, i18n, doUseDefaultCss, Template } = props ;
@@ -13,38 +14,46 @@ export default function Account(props: PageProps<Extract<KcContext, { pageId: "a
13
14
kcBodyClass : clsx ( props . classes ?. kcBodyClass , "user" )
14
15
} ;
15
16
17
+ const { goToAuthServer } = useOidc ( ) ;
16
18
const { referrer } = kcContext ;
17
19
18
20
const { msg } = i18n ;
19
21
20
22
return (
21
23
< Template { ...{ kcContext, i18n, doUseDefaultCss, classes } } active = "account" >
22
24
< h2 className = { fr . cx ( "fr-h2" ) } > { msg ( "editAccountHtmlTitle" ) } </ h2 >
23
- < ButtonsGroup
25
+ < ButtonsGroup
24
26
buttons = { [
25
27
{
26
- children : "Update profil" ,
27
- linkProps : {
28
- href : `/realms/myrealm/login-actions/required-action?execution=UPDATE_PROFILE&client_id=${ referrer ?. name } ` ,
29
- } ,
28
+ children : msg ( "updateProfile" ) ,
29
+ onClick : ( ) =>
30
+ goToAuthServer ( {
31
+ extraQueryParams : { kc_action : "UPDATE_PROFILE" }
32
+ } )
30
33
} ,
31
34
{
32
- children : "Update password" ,
33
- linkProps : {
34
- href : `/realms/myrealm/login-actions/required-action?execution=UPDATE_PASSWORD&client_id=${ referrer ?. name } ` ,
35
- } ,
35
+ children : msg ( "updatePasswordTitle" ) ,
36
+ onClick : ( ) =>
37
+ goToAuthServer ( {
38
+ extraQueryParams : { kc_action : "UPDATE_PASSWORD" }
39
+ } )
36
40
} ,
37
41
{
38
- children : "Delete account" ,
39
- linkProps : {
40
- href : `/realms/myrealm/login-actions/required-action?execution=delete_account&client_id=${ referrer ?. name } ` ,
41
- } ,
42
+ children : msg ( "deleteAccount" ) ,
43
+ onClick : ( ) =>
44
+ goToAuthServer ( {
45
+ extraQueryParams : { kc_action : "delete_account" }
46
+ } ) ,
42
47
priority : "secondary"
43
48
}
44
49
] }
45
50
/>
46
51
47
- { referrer && < a className = { fr . cx ( "fr-link" ) } href = { referrer ?. url } > { msg ( "backTo" , referrer . name ) } </ a > }
52
+ { referrer && (
53
+ < a className = { fr . cx ( "fr-link" ) } href = { referrer ?. url } >
54
+ { msg ( "backTo" , referrer . name ) }
55
+ </ a >
56
+ ) }
48
57
</ Template >
49
58
) ;
50
59
}
0 commit comments