@@ -10,6 +10,7 @@ import { useState } from "react";
10
10
import type { KcContext } from "../KcContext" ;
11
11
import type { I18n } from "../i18n" ;
12
12
import "./login.css" ;
13
+ const franceConnectProviderIds = [ "franceconnect" , "franceconnect-particulier" ] ;
13
14
export default function Login ( props : PageProps < Extract < KcContext , { pageId : "login.ftl" } > , I18n > ) {
14
15
const { kcContext, i18n, doUseDefaultCss, Template, classes } = props ;
15
16
@@ -52,12 +53,15 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
52
53
< hr />
53
54
< div >
54
55
{ social . providers
55
- . map ( ( ... [ p ] ) => {
56
+ . map ( ( p , index ) => {
56
57
if ( p . providerId === "agentconnect" || p . providerId === "proconnect" ) {
57
58
return < ProConnectButton key = { p . alias } style = { { textAlign : "center" } } url = { p . loginUrl } /> ;
58
59
}
59
60
60
- if ( p . providerId === "franceconnect" || p . providerId === "franceconnect-particulier" ) {
61
+ if ( franceConnectProviderIds . includes ( p . providerId ) ) {
62
+ if ( index !== 0 ) {
63
+ throw new Error ( 'Le bouton FranceConnect doit être le premier bouton de connexion' ) ;
64
+ }
61
65
return (
62
66
< >
63
67
< p className = { fr . cx ( "fr-text--light" ) } >
@@ -70,42 +74,47 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
70
74
}
71
75
72
76
return (
73
- < Button
74
- className = { fr . cx ( "fr-m-1w" ) }
75
- key = { p . alias }
76
- iconId = { ( ( ) => {
77
- switch ( p . providerId ) {
78
- case "github" :
79
- return "ri-github-fill" ;
80
- case "google" :
81
- return "ri-google-fill" ;
82
- case "facebook" :
83
- return "ri-facebook-fill" ;
84
- case "microsoft" :
85
- return "ri-microsoft-fill" ;
86
- case "twitter" :
87
- return "ri-twitter-fill" ;
88
- case "instagram" :
89
- return "ri-instagram-fill" ;
90
- case "linkedin" :
91
- return "ri-linkedin-fill" ;
92
- case "stackoverflow" :
93
- return "ri-stack-overflow-fill" ;
94
- case "gitlab" :
95
- return "ri-gitlab-fill" ;
96
- }
97
- return "ri-external-link-line" ;
98
- } ) ( ) }
99
- linkProps = { {
100
- href : p . loginUrl
101
- } }
102
- >
103
- { p . displayName }
104
- </ Button >
77
+ < div style = { {
78
+ display : 'flex' ,
79
+ justifyContent : 'center'
80
+ } } >
81
+ < Button
82
+ className = { fr . cx ( "fr-m-1w" ) }
83
+ key = { p . alias }
84
+ iconId = { ( ( ) => {
85
+ switch ( p . providerId ) {
86
+ case "github" :
87
+ return "ri-github-fill" ;
88
+ case "google" :
89
+ return "ri-google-fill" ;
90
+ case "facebook" :
91
+ return "ri-facebook-fill" ;
92
+ case "microsoft" :
93
+ return "ri-microsoft-fill" ;
94
+ case "twitter" :
95
+ return "ri-twitter-fill" ;
96
+ case "instagram" :
97
+ return "ri-instagram-fill" ;
98
+ case "linkedin" :
99
+ return "ri-linkedin-fill" ;
100
+ case "stackoverflow" :
101
+ return "ri-stack-overflow-fill" ;
102
+ case "gitlab" :
103
+ return "ri-gitlab-fill" ;
104
+ }
105
+ return "ri-external-link-line" ;
106
+ } ) ( ) }
107
+ linkProps = { {
108
+ href : p . loginUrl
109
+ } }
110
+ >
111
+ { p . displayName }
112
+ </ Button >
113
+ </ div >
105
114
) ;
106
115
} )
107
116
. map ( ( value , index ) => {
108
- if ( index >= 1 ) {
117
+ if ( index >= 1 && franceConnectProviderIds . includes ( social . providers ?. [ 0 ] . providerId ?? '' ) ) {
109
118
return (
110
119
< >
111
120
< div className = "separator" > OU</ div >
0 commit comments