@@ -9,14 +9,11 @@ Please see LICENSE files in the repository root for full details.
99import React , { type JSX , memo , type ReactNode } from "react" ;
1010import classNames from "classnames" ;
1111import { logger } from "matrix-js-sdk/src/logger" ;
12- import { type SSOFlow , type MatrixClient , SSOAction } from "matrix-js-sdk/src/matrix" ;
12+ import { type SSOFlow , SSOAction } from "matrix-js-sdk/src/matrix" ;
1313import { Button } from "@vector-im/compound-web" ;
14- import { QrCodeIcon } from "@vector-im/compound-design-tokens/assets/web/icons" ;
15- import { secureRandomString } from "matrix-js-sdk/src/randomstring" ;
16- import { RendezvousIntent } from "matrix-js-sdk/src/rendezvous" ;
1714
1815import { _t , UserFriendlyError } from "../../../languageHandler" ;
19- import Login , { type LoginWithQrFlow , type ClientLoginFlow , type OidcNativeFlow } from "../../../Login" ;
16+ import Login , { type ClientLoginFlow , type OidcNativeFlow } from "../../../Login" ;
2017import { messageForConnectionError , messageForLoginError } from "../../../utils/ErrorUtils" ;
2118import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils" ;
2219import AuthPage from "../../views/auth/AuthPage" ;
@@ -36,9 +33,6 @@ import { type ValidatedServerConfig } from "../../../utils/ValidatedServerConfig
3633import { filterBoolean } from "../../../utils/arrays" ;
3734import { startOidcLogin } from "../../../utils/oidc/authorize" ;
3835import { ModuleApi } from "../../../modules/Api.ts" ;
39- import LoginWithQR from "../../views/auth/LoginWithQR.tsx" ;
40- import { Mode } from "../../views/auth/LoginWithQR-types.ts" ;
41- import createMatrixClient from "../../../utils/createMatrixClient.ts" ;
4236
4337interface IProps {
4438 serverConfig : ValidatedServerConfig ;
@@ -57,8 +51,7 @@ interface IProps {
5751
5852 // Called when the user has logged in. Params:
5953 // - The object returned by the login API
60- // - alreadySignedIn: true if the user was already signed in (e.g. QR login) and only the post login setup is needed
61- onLoggedIn ( data : IMatrixClientCreds , alreadySignedIn ?: boolean ) : void ;
54+ onLoggedIn ( data : IMatrixClientCreds ) : void ;
6255
6356 // login shouldn't know or care how registration, password recovery, etc is done.
6457 onRegisterClick ?( ) : void ;
@@ -86,9 +79,6 @@ interface IState {
8679 serverIsAlive : boolean ;
8780 serverErrorIsFatal : boolean ;
8881 serverDeadError ?: ReactNode ;
89-
90- loginWithQrInProgress : boolean ;
91- loginWithQrClient ?: MatrixClient ;
9282}
9383
9484type OnPasswordLogin = {
@@ -120,8 +110,6 @@ class LoginComponent extends React.PureComponent<IProps, IState> {
120110 serverIsAlive : true ,
121111 serverErrorIsFatal : false ,
122112 serverDeadError : "" ,
123-
124- loginWithQrInProgress : false ,
125113 } ;
126114
127115 // map from login step type to a function which will render a control
@@ -135,7 +123,6 @@ class LoginComponent extends React.PureComponent<IProps, IState> {
135123 // eslint-disable-next-line @typescript-eslint/naming-convention
136124 "m.login.sso" : ( ) => this . renderSsoStep ( "sso" ) ,
137125 "oidcNativeFlow" : ( ) => this . renderOidcNativeStep ( ) ,
138- "loginWithQrFlow" : ( ) => this . renderLoginWithQRStep ( ) ,
139126 } ;
140127 }
141128
@@ -415,7 +402,7 @@ class LoginComponent extends React.PureComponent<IProps, IState> {
415402 if ( ! this . state . flows ) return null ;
416403
417404 // this is the ideal order we want to show the flows in
418- const order = [ "loginWithQrFlow" , " oidcNativeFlow", "m.login.password" , "m.login.sso" ] ;
405+ const order = [ "oidcNativeFlow" , "m.login.password" , "m.login.sso" ] ;
419406
420407 const flows = filterBoolean ( order . map ( ( type ) => this . state . flows ?. find ( ( flow ) => flow . type === type ) ) ) ;
421408 return (
@@ -485,42 +472,6 @@ class LoginComponent extends React.PureComponent<IProps, IState> {
485472 ) ;
486473 } ;
487474
488- private startLoginWithQR = ( ) : void => {
489- if ( this . state . loginWithQrInProgress ) return ;
490- // pick our device ID
491- const deviceId = secureRandomString ( 10 ) ;
492- const loginWithQrClient = createMatrixClient ( {
493- baseUrl : this . loginLogic . getHomeserverUrl ( ) ,
494- idBaseUrl : this . loginLogic . getIdentityServerUrl ( ) ,
495- deviceId,
496- } ) ;
497- this . setState ( { loginWithQrInProgress : true , loginWithQrClient } ) ;
498- } ;
499-
500- private renderLoginWithQRStep = ( ) : JSX . Element => {
501- return (
502- < >
503- < Button className = "mx_Login_fullWidthButton" kind = "primary" size = "sm" onClick = { this . startLoginWithQR } >
504- < QrCodeIcon />
505- { _t ( "auth|sign_in_with_qr" ) }
506- </ Button >
507- </ >
508- ) ;
509- } ;
510-
511- private onLoginWithQRFinished = ( success : boolean , credentials ?: IMatrixClientCreds ) : void => {
512- if ( credentials ) {
513- this . props . onLoggedIn ( credentials , true ) ;
514- } else if ( ! success ) {
515- this . state . loginWithQrClient ?. stopClient ( ) ;
516- this . setState ( { loginWithQrInProgress : false , loginWithQrClient : undefined } ) ;
517- }
518- } ;
519-
520- private get qrClientId ( ) : string {
521- return ( this . state . flows ?. find ( ( flow ) => flow . type === "loginWithQrFlow" ) as LoginWithQrFlow ) . clientId ?? "" ;
522- }
523-
524475 public render ( ) : React . ReactNode {
525476 const loader =
526477 this . isBusy ( ) && ! this . state . busyLoggingIn ? (
@@ -581,35 +532,20 @@ class LoginComponent extends React.PureComponent<IProps, IState> {
581532 < AuthPage >
582533 < AuthHeader disableLanguageSelector = { this . props . isSyncing || this . state . busyLoggingIn } />
583534 < AuthBody >
584- { this . state . loginWithQrInProgress ? (
585- < >
586- < LoginWithQR
587- onFinished = { this . onLoginWithQRFinished }
588- mode = { Mode . Show }
589- intent = { RendezvousIntent . LOGIN_ON_NEW_DEVICE }
590- client = { this . state . loginWithQrClient ! }
591- clientId = { this . qrClientId }
592- />
593- </ >
594- ) : (
595- < >
596- { " " }
597- < h1 >
598- { _t ( "action|sign_in" ) }
599- { loader }
600- </ h1 >
601- { errorTextSection }
602- { serverDeadSection }
603- < ServerPicker
604- serverConfig = { this . props . serverConfig }
605- onServerConfigChange = { this . props . onServerConfigChange }
606- disabled = { this . isBusy ( ) }
607- />
608- { this . renderLoginComponentForFlows ( ) }
609- { this . props . children }
610- { footer }
611- </ >
612- ) }
535+ < h1 >
536+ { _t ( "action|sign_in" ) }
537+ { loader }
538+ </ h1 >
539+ { errorTextSection }
540+ { serverDeadSection }
541+ < ServerPicker
542+ serverConfig = { this . props . serverConfig }
543+ onServerConfigChange = { this . props . onServerConfigChange }
544+ disabled = { this . isBusy ( ) }
545+ />
546+ { this . renderLoginComponentForFlows ( ) }
547+ { this . props . children }
548+ { footer }
613549 </ AuthBody >
614550 </ AuthPage >
615551 ) ;
0 commit comments