1
1
import { fr } from "@codegouvfr/react-dsfr" ;
2
2
import { Button } from "@codegouvfr/react-dsfr/Button" ;
3
3
import { Input } from "@codegouvfr/react-dsfr/Input" ;
4
+ import { FranceConnectButton } from "@codegouvfr/react-dsfr/FranceConnectButton" ;
5
+ import { AgentConnectButton } from "@codegouvfr/react-dsfr/AgentConnectButton" ;
6
+ import { ProConnectButton } from "@codegouvfr/react-dsfr/ProConnectButton" ;
4
7
import { PasswordInput } from "@codegouvfr/react-dsfr/blocks/PasswordInput" ;
5
- import { kcSanitize } from "keycloakify/lib/kcSanitize" ;
6
8
import { getKcClsx } from "keycloakify/login/lib/kcClsx" ;
7
9
import type { PageProps } from "keycloakify/login/pages/PageProps" ;
8
- import { clsx } from "keycloakify/tools/clsx" ;
9
10
import { useState } from "react" ;
10
11
import type { KcContext } from "../KcContext" ;
11
12
import type { I18n } from "../i18n" ;
@@ -23,7 +24,7 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
23
24
const { msg, msgStr } = i18n ;
24
25
25
26
const [ isLoginButtonDisabled , setIsLoginButtonDisabled ] = useState ( false ) ;
26
-
27
+
27
28
return (
28
29
< Template
29
30
kcContext = { kcContext }
@@ -50,27 +51,55 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
50
51
{ realm . password && social ?. providers !== undefined && social . providers . length !== 0 && (
51
52
< div id = "kc-social-providers" className = { kcClsx ( "kcFormSocialAccountSectionClass" ) } >
52
53
< hr />
53
- < h2 > { msg ( "identity-provider-login-label" ) } </ h2 >
54
- < ul className = { kcClsx ( "kcFormSocialAccountListClass" , social . providers . length > 3 && "kcFormSocialAccountListGridClass" ) } >
55
- { social . providers . map ( ( ...[ p , , providers ] ) => (
56
- < li key = { p . alias } >
57
- < a
58
- id = { `social-${ p . alias } ` }
59
- className = { kcClsx (
60
- "kcFormSocialAccountListButtonClass" ,
61
- providers . length > 3 && "kcFormSocialAccountGridItem"
62
- ) }
63
- type = "button"
64
- href = { p . loginUrl }
54
+ < ul >
55
+ { social . providers . map ( ( ...[ p ] ) => {
56
+ if ( p . providerId === "proConnect" ) {
57
+ return < ProConnectButton key = { p . alias } style = { { textAlign : "center" } } url = { p . loginUrl } /> ;
58
+ }
59
+
60
+ if ( p . providerId === "agentconnect" ) {
61
+ return < AgentConnectButton key = { p . alias } style = { { textAlign : "center" } } url = { p . loginUrl } /> ;
62
+ }
63
+
64
+ if ( p . providerId === "franceconnect" ) {
65
+ return < FranceConnectButton key = { p . alias } style = { { textAlign : "center" } } url = { p . loginUrl } /> ;
66
+ }
67
+
68
+ return (
69
+ < Button
70
+ className = { fr . cx ( "fr-m-1w" ) }
71
+ key = { p . alias }
72
+ iconId = { ( ( ) => {
73
+ switch ( p . providerId ) {
74
+ case "github" :
75
+ return "ri-github-fill" ;
76
+ case "google" :
77
+ return "ri-google-fill" ;
78
+ case "facebook" :
79
+ return "ri-facebook-fill" ;
80
+ case "microsoft" :
81
+ return "ri-microsoft-fill" ;
82
+ case "twitter" :
83
+ return "ri-twitter-fill" ;
84
+ case "instagram" :
85
+ return "ri-instagram-fill" ;
86
+ case "linkedin" :
87
+ return "ri-linkedin-fill" ;
88
+ case "stackoverflow" :
89
+ return "ri-stack-overflow-fill" ;
90
+ case "gitlab" :
91
+ return "ri-gitlab-fill" ;
92
+ }
93
+ return "ri-external-link-line" ;
94
+ } ) ( ) }
95
+ linkProps = { {
96
+ href : p . loginUrl
97
+ } }
65
98
>
66
- { p . iconClasses && < i className = { clsx ( kcClsx ( "kcCommonLogoIdP" ) , p . iconClasses ) } aria-hidden = "true" > </ i > }
67
- < span
68
- className = { clsx ( kcClsx ( "kcFormSocialAccountNameClass" ) , p . iconClasses && "kc-social-icon-text" ) }
69
- dangerouslySetInnerHTML = { { __html : kcSanitize ( p . displayName ) } }
70
- > </ span >
71
- </ a >
72
- </ li >
73
- ) ) }
99
+ { p . displayName }
100
+ </ Button >
101
+ ) ;
102
+ } ) }
74
103
</ ul >
75
104
</ div >
76
105
) }
@@ -79,6 +108,7 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
79
108
>
80
109
< div id = "kc-form" >
81
110
< div id = "kc-form-wrapper" >
111
+ { social ?. providers !== undefined && social . providers . length !== 0 && < h2 > { msg ( "or-login-with-email" ) } </ h2 > }
82
112
{ realm . password && (
83
113
< form
84
114
id = "kc-form-login"
@@ -122,7 +152,7 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
122
152
}
123
153
/>
124
154
125
- < div style = { { display : "flex" , justifyContent : "space-between" } } >
155
+ < div style = { { display : "flex" , justifyContent : "space-between" } } >
126
156
< div >
127
157
{ realm . rememberMe && ! usernameHidden && (
128
158
< div className = { fr . cx ( "fr-checkbox-group" , "fr-checkbox-group--sm" ) } >
@@ -139,10 +169,9 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
139
169
</ div >
140
170
{ realm . resetPasswordAllowed && (
141
171
< div >
142
-
143
- < a className = { fr . cx ( "fr-link" ) } href = { url . loginResetCredentialsUrl } tabIndex = { 6 } >
144
- { msg ( "doForgotPassword" ) }
145
- </ a >
172
+ < a className = { fr . cx ( "fr-link" ) } href = { url . loginResetCredentialsUrl } tabIndex = { 6 } >
173
+ { msg ( "doForgotPassword" ) }
174
+ </ a >
146
175
</ div >
147
176
) }
148
177
</ div >
0 commit comments