@@ -18,6 +18,7 @@ limitations under the License.
1818*/
1919
2020import React , { createRef } from 'react' ;
21+ import { createClient } from "matrix-js-sdk/src" ;
2122import { InvalidStoreError } from "matrix-js-sdk/src/errors" ;
2223import { RoomMember } from "matrix-js-sdk/src/models/room-member" ;
2324import { MatrixEvent } from "matrix-js-sdk/src/models/event" ;
@@ -1612,6 +1613,19 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
16121613 } ) ;
16131614 } else if ( screen === 'directory' ) {
16141615 dis . fire ( Action . ViewRoomDirectory ) ;
1616+ } else if ( screen === "start_sso" || screen === "start_cas" ) {
1617+ // TODO if logged in, skip SSO
1618+ let cli = MatrixClientPeg . get ( ) ;
1619+ if ( ! cli ) {
1620+ const { hsUrl, isUrl} = this . props . serverConfig ;
1621+ cli = createClient ( {
1622+ baseUrl : hsUrl ,
1623+ idBaseUrl : isUrl ,
1624+ } ) ;
1625+ }
1626+
1627+ const type = screen === "start_sso" ? "sso" : "cas" ;
1628+ PlatformPeg . get ( ) . startSingleSignOn ( cli , type , this . getFragmentAfterLogin ( ) ) ;
16151629 } else if ( screen === 'groups' ) {
16161630 dis . dispatch ( {
16171631 action : 'view_my_groups' ,
@@ -1915,17 +1929,19 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
19151929 this . onLoggedIn ( ) ;
19161930 } ;
19171931
1918- render ( ) {
1919- // console.log(`Rendering MatrixChat with view ${this.state.view}`);
1920-
1932+ getFragmentAfterLogin ( ) {
19211933 let fragmentAfterLogin = "" ;
19221934 if ( this . props . initialScreenAfterLogin &&
19231935 // XXX: workaround for https://github.com/vector-im/riot-web/issues/11643 causing a login-loop
19241936 ! [ "welcome" , "login" , "register" ] . includes ( this . props . initialScreenAfterLogin . screen )
19251937 ) {
19261938 fragmentAfterLogin = `/${ this . props . initialScreenAfterLogin . screen } ` ;
19271939 }
1940+ return fragmentAfterLogin ;
1941+ }
19281942
1943+ render ( ) {
1944+ const fragmentAfterLogin = this . getFragmentAfterLogin ( ) ;
19291945 let view ;
19301946
19311947 if ( this . state . view === Views . LOADING ) {
@@ -2004,7 +2020,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
20042020 }
20052021 } else if ( this . state . view === Views . WELCOME ) {
20062022 const Welcome = sdk . getComponent ( 'auth.Welcome' ) ;
2007- view = < Welcome { ... this . getServerProperties ( ) } fragmentAfterLogin = { fragmentAfterLogin } /> ;
2023+ view = < Welcome /> ;
20082024 } else if ( this . state . view === Views . REGISTER ) {
20092025 const Registration = sdk . getComponent ( 'structures.auth.Registration' ) ;
20102026 view = (
0 commit comments