@@ -19,7 +19,13 @@ import { chunk } from "lodash";
1919import classNames from "classnames" ;
2020import { MatrixClient } from "matrix-js-sdk/src/client" ;
2121import { Signup } from "@matrix-org/analytics-events/types/typescript/Signup" ;
22- import { IdentityProviderBrand , IIdentityProvider , ISSOFlow } from "matrix-js-sdk/src/@types/auth" ;
22+ import {
23+ IdentityProviderBrand ,
24+ IIdentityProvider ,
25+ ISSOFlow ,
26+ DELEGATED_OIDC_COMPATIBILITY ,
27+ SSOAction ,
28+ } from "matrix-js-sdk/src/@types/auth" ;
2329
2430import PlatformPeg from "../../../PlatformPeg" ;
2531import AccessibleButton from "./AccessibleButton" ;
@@ -28,9 +34,10 @@ import AccessibleTooltipButton from "./AccessibleTooltipButton";
2834import { mediaFromMxc } from "../../../customisations/Media" ;
2935import { PosthogAnalytics } from "../../../PosthogAnalytics" ;
3036
31- interface ISSOButtonProps extends Omit < IProps , "flow" > {
37+ interface ISSOButtonProps extends IProps {
3238 idp ?: IIdentityProvider ;
3339 mini ?: boolean ;
40+ action ?: SSOAction ;
3441}
3542
3643const getIcon = ( brand : IdentityProviderBrand | string ) : string | null => {
@@ -79,20 +86,29 @@ const SSOButton: React.FC<ISSOButtonProps> = ({
7986 idp,
8087 primary,
8188 mini,
89+ action,
90+ flow,
8291 ...props
8392} ) => {
84- const label = idp ? _t ( "Continue with %(provider)s" , { provider : idp . name } ) : _t ( "Sign in with single sign-on" ) ;
93+ let label : string ;
94+ if ( idp ) {
95+ label = _t ( "Continue with %(provider)s" , { provider : idp . name } ) ;
96+ } else if ( DELEGATED_OIDC_COMPATIBILITY . findIn < boolean > ( flow ) ) {
97+ label = _t ( "Continue" ) ;
98+ } else {
99+ label = _t ( "Sign in with single sign-on" ) ;
100+ }
85101
86102 const onClick = ( ) : void => {
87103 const authenticationType = getAuthenticationType ( idp ?. brand ?? "" ) ;
88104 PosthogAnalytics . instance . setAuthenticationType ( authenticationType ) ;
89- PlatformPeg . get ( ) . startSingleSignOn ( matrixClient , loginType , fragmentAfterLogin , idp ?. id ) ;
105+ PlatformPeg . get ( ) ? .startSingleSignOn ( matrixClient , loginType , fragmentAfterLogin , idp ?. id , action ) ;
90106 } ;
91107
92- let icon ;
93- let brandClass ;
94- const brandIcon = idp ? getIcon ( idp . brand ) : null ;
95- if ( brandIcon ) {
108+ let icon : JSX . Element | undefined ;
109+ let brandClass : string | undefined ;
110+ const brandIcon = idp ?. brand ? getIcon ( idp . brand ) : null ;
111+ if ( idp ?. brand && brandIcon ) {
96112 const brandName = idp . brand . split ( "." ) . pop ( ) ;
97113 brandClass = `mx_SSOButton_brand_${ brandName } ` ;
98114 icon = < img src = { brandIcon } height = "24" width = "24" alt = { brandName } /> ;
@@ -101,12 +117,16 @@ const SSOButton: React.FC<ISSOButtonProps> = ({
101117 icon = < img src = { src } height = "24" width = "24" alt = { idp . name } /> ;
102118 }
103119
104- const classes = classNames ( "mx_SSOButton" , {
105- [ brandClass ] : brandClass ,
106- mx_SSOButton_mini : mini ,
107- mx_SSOButton_default : ! idp ,
108- mx_SSOButton_primary : primary ,
109- } ) ;
120+ const brandPart = brandClass ? { [ brandClass ] : brandClass } : undefined ;
121+ const classes = classNames (
122+ "mx_SSOButton" ,
123+ {
124+ mx_SSOButton_mini : mini ,
125+ mx_SSOButton_default : ! idp ,
126+ mx_SSOButton_primary : primary ,
127+ } ,
128+ brandPart ,
129+ ) ;
110130
111131 if ( mini ) {
112132 // TODO fallback icon
@@ -128,14 +148,15 @@ const SSOButton: React.FC<ISSOButtonProps> = ({
128148interface IProps {
129149 matrixClient : MatrixClient ;
130150 flow : ISSOFlow ;
131- loginType ? : "sso" | "cas" ;
151+ loginType : "sso" | "cas" ;
132152 fragmentAfterLogin ?: string ;
133153 primary ?: boolean ;
154+ action ?: SSOAction ;
134155}
135156
136157const MAX_PER_ROW = 6 ;
137158
138- const SSOButtons : React . FC < IProps > = ( { matrixClient, flow, loginType, fragmentAfterLogin, primary } ) => {
159+ const SSOButtons : React . FC < IProps > = ( { matrixClient, flow, loginType, fragmentAfterLogin, primary, action } ) => {
139160 const providers = flow . identity_providers || [ ] ;
140161 if ( providers . length < 2 ) {
141162 return (
@@ -146,6 +167,8 @@ const SSOButtons: React.FC<IProps> = ({ matrixClient, flow, loginType, fragmentA
146167 fragmentAfterLogin = { fragmentAfterLogin }
147168 idp = { providers [ 0 ] }
148169 primary = { primary }
170+ action = { action }
171+ flow = { flow }
149172 />
150173 </ div >
151174 ) ;
@@ -167,6 +190,8 @@ const SSOButtons: React.FC<IProps> = ({ matrixClient, flow, loginType, fragmentA
167190 idp = { idp }
168191 mini = { true }
169192 primary = { primary }
193+ action = { action }
194+ flow = { flow }
170195 />
171196 ) ) }
172197 </ div >
0 commit comments