@@ -140,7 +140,7 @@ import { cleanUpDraftsIfRequired } from "../../DraftCleaner";
140
140
// legacy export
141
141
export { default as Views } from "../../Views" ;
142
142
143
- const AUTH_SCREENS = [ "register" , "login" , "forgot_password" , "start_sso" , "start_cas" , "welcome" ] ;
143
+ const AUTH_SCREENS = [ "register" , "mobile_register" , " login", "forgot_password" , "start_sso" , "start_cas" , "welcome" ] ;
144
144
145
145
// Actions that are redirected through the onboarding process prior to being
146
146
// re-dispatched. NOTE: some actions are non-trivial and would require
@@ -189,6 +189,7 @@ interface IState {
189
189
register_session_id ?: string ;
190
190
// eslint-disable-next-line camelcase
191
191
register_id_sid ?: string ;
192
+ isMobileRegistration ?: boolean ;
192
193
// When showing Modal dialogs we need to set aria-hidden on the root app element
193
194
// and disable it when there are no dialogs
194
195
hideToSRUsers : boolean ;
@@ -243,6 +244,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
243
244
currentUserId : null ,
244
245
245
246
hideToSRUsers : false ,
247
+ isMobileRegistration : false ,
246
248
247
249
syncError : null , // If the current syncing status is ERROR, the error object, otherwise null.
248
250
resizeNotifier : new ResizeNotifier ( ) ,
@@ -650,6 +652,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
650
652
case "require_registration" :
651
653
startAnyRegistrationFlow ( payload as any ) ;
652
654
break ;
655
+ case "start_mobile_registration" :
656
+ this . startRegistration ( payload . params || { } , true ) ;
657
+ break ;
653
658
case "start_registration" :
654
659
if ( Lifecycle . isSoftLogout ( ) ) {
655
660
this . onSoftLogout ( ) ;
@@ -946,19 +951,28 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
946
951
} ) ;
947
952
}
948
953
949
- private async startRegistration ( params : { [ key : string ] : string } ) : Promise < void > {
954
+ private async startRegistration ( params : { [ key : string ] : string } , isMobileRegistration ?: boolean ) : Promise < void > {
950
955
if ( ! SettingsStore . getValue ( UIFeature . Registration ) ) {
951
956
this . showScreen ( "welcome" ) ;
952
957
return ;
953
958
}
959
+ const isMobileRegistrationAllowed =
960
+ isMobileRegistration && SettingsStore . getValue ( "Registration.mobileRegistrationHelper" ) ;
954
961
955
962
const newState : Partial < IState > = {
956
963
view : Views . REGISTER ,
957
964
} ;
958
965
959
- // Only honour params if they are all present, otherwise we reset
960
- // HS and IS URLs when switching to registration.
961
- if ( params . client_secret && params . session_id && params . hs_url && params . is_url && params . sid ) {
966
+ if ( isMobileRegistrationAllowed && params . hs_url ) {
967
+ try {
968
+ const config = await AutoDiscoveryUtils . validateServerConfigWithStaticUrls ( params . hs_url ) ;
969
+ newState . serverConfig = config ;
970
+ } catch ( err ) {
971
+ logger . warn ( "Failed to load hs_url param:" , params . hs_url ) ;
972
+ }
973
+ } else if ( params . client_secret && params . session_id && params . hs_url && params . is_url && params . sid ) {
974
+ // Only honour params if they are all present, otherwise we reset
975
+ // HS and IS URLs when switching to registration.
962
976
newState . serverConfig = await AutoDiscoveryUtils . validateServerConfigWithStaticUrls (
963
977
params . hs_url ,
964
978
params . is_url ,
@@ -978,10 +992,12 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
978
992
newState . register_id_sid = params . sid ;
979
993
}
980
994
995
+ newState . isMobileRegistration = isMobileRegistrationAllowed ;
996
+
981
997
this . setStateForNewView ( newState ) ;
982
998
ThemeController . isLogin = true ;
983
999
this . themeWatcher . recheck ( ) ;
984
- this . notifyNewScreen ( "register" ) ;
1000
+ this . notifyNewScreen ( isMobileRegistrationAllowed ? "mobile_register" : "register" ) ;
985
1001
}
986
1002
987
1003
// switch view to the given room
@@ -1721,6 +1737,11 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
1721
1737
params : params ,
1722
1738
} ) ;
1723
1739
PerformanceMonitor . instance . start ( PerformanceEntryNames . REGISTER ) ;
1740
+ } else if ( screen === "mobile_register" ) {
1741
+ dis . dispatch ( {
1742
+ action : "start_mobile_registration" ,
1743
+ params : params ,
1744
+ } ) ;
1724
1745
} else if ( screen === "login" ) {
1725
1746
dis . dispatch ( {
1726
1747
action : "start_login" ,
@@ -2080,6 +2101,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
2080
2101
onServerConfigChange = { this . onServerConfigChange }
2081
2102
defaultDeviceDisplayName = { this . props . defaultDeviceDisplayName }
2082
2103
fragmentAfterLogin = { fragmentAfterLogin }
2104
+ mobileRegister = { this . state . isMobileRegistration }
2083
2105
{ ...this . getServerProperties ( ) }
2084
2106
/>
2085
2107
) ;
0 commit comments