@@ -10,6 +10,7 @@ import { useState } from "react";
1010import type { KcContext } from "../KcContext" ;
1111import type { I18n } from "../i18n" ;
1212import "./login.css" ;
13+ const franceConnectProviderIds = [ "franceconnect" , "franceconnect-particulier" ] ;
1314export default function Login ( props : PageProps < Extract < KcContext , { pageId : "login.ftl" } > , I18n > ) {
1415 const { kcContext, i18n, doUseDefaultCss, Template, classes } = props ;
1516
@@ -52,12 +53,15 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
5253 < hr />
5354 < div >
5455 { social . providers
55- . map ( ( ... [ p ] ) => {
56+ . map ( ( p , index ) => {
5657 if ( p . providerId === "agentconnect" || p . providerId === "proconnect" ) {
5758 return < ProConnectButton key = { p . alias } style = { { textAlign : "center" } } url = { p . loginUrl } /> ;
5859 }
5960
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+ }
6165 return (
6266 < >
6367 < p className = { fr . cx ( "fr-text--light" ) } >
@@ -70,42 +74,47 @@ export default function Login(props: PageProps<Extract<KcContext, { pageId: "log
7074 }
7175
7276 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 >
105114 ) ;
106115 } )
107116 . map ( ( value , index ) => {
108- if ( index >= 1 ) {
117+ if ( index >= 1 && franceConnectProviderIds . includes ( social . providers ?. [ 0 ] . providerId ?? '' ) ) {
109118 return (
110119 < >
111120 < div className = "separator" > OU</ div >
0 commit comments