@@ -176,13 +176,7 @@ type OuterProps = $ReadOnly<{|
176
176
route : RouteProp < 'auth' , { | serverSettings : ServerSettings | } > ,
177
177
| } > ;
178
178
179
- type SelectorProps = $ReadOnly < { |
180
- // Don't let this change across the component's lifecycle. It must be
181
- // clear and predictable which realm the user is entrusting their
182
- // credentials to. (And other sensitive info, e.g., from the Apple auth
183
- // native flow.)
184
- realm : URL ,
185
- | } > ;
179
+ type SelectorProps = $ReadOnly < { || } > ;
186
180
187
181
type Props = $ReadOnly < { |
188
182
...OuterProps ,
@@ -237,26 +231,32 @@ class AuthScreenInner extends PureComponent<Props> {
237
231
*/
238
232
beginWebAuth = async ( url : string ) => {
239
233
otp = await webAuth . generateOtp ( ) ;
240
- webAuth . openBrowser ( new URL ( url , this . props . realm ) . toString ( ) , otp ) ;
234
+ webAuth . openBrowser (
235
+ new URL ( url , this . props . route . params . serverSettings . realm_uri ) . toString ( ) ,
236
+ otp ,
237
+ ) ;
241
238
} ;
242
239
243
240
endWebAuth = ( event : LinkingEvent ) = > {
244
241
webAuth . closeBrowser ( ) ;
245
242
246
- const { dispatch , realm } = this . props ;
243
+ const { dispatch } = this . props ;
244
+ const realm = this . props . route . params . serverSettings . realm_uri ;
247
245
const auth = webAuth . authFromCallbackUrl ( event . url , otp , realm ) ;
248
246
if ( auth ) {
249
247
dispatch ( loginSuccess ( auth . realm , auth . email , auth . apiKey ) ) ;
250
248
}
251
249
} ;
252
250
253
251
handleDevAuth = ( ) = > {
254
- this . props . navigation . push ( 'dev-auth' , { realm : this . props . realm } ) ;
252
+ this . props . navigation . push ( 'dev-auth' , {
253
+ realm : this . props . route . params . serverSettings . realm_uri ,
254
+ } ) ;
255
255
} ;
256
256
257
257
handlePassword = () => {
258
258
const { serverSettings } = this.props.route.params;
259
- const { realm } = this.props ;
259
+ const realm = serverSettings.realm_uri ;
260
260
this.props.navigation.push('password-auth', {
261
261
realm ,
262
262
requireEmailFormat : serverSettings . require_email_format_usernames ,
@@ -284,7 +284,12 @@ class AuthScreenInner extends PureComponent<Props> {
284
284
id_token : credential . identityToken ,
285
285
} );
286
286
287
- openLinkEmbedded(new URL(`/complete/apple/?${ params } `, this.props.realm).toString());
287
+ openLinkEmbedded(
288
+ new URL(
289
+ `/complete/apple/?${ params } `,
290
+ this.props.route.params.serverSettings.realm_uri,
291
+ ).toString(),
292
+ );
288
293
289
294
// Currently, the rest is handled with the `zulip://` redirect,
290
295
// same as in the web flow.
@@ -306,7 +311,7 @@ class AuthScreenInner extends PureComponent<Props> {
306
311
//
307
312
// (For other realms, we'll simply fall back to the web flow, which
308
313
// handles things appropriately without relying on that assumption.)
309
- return isAppOwnDomain(this.props.realm );
314
+ return isAppOwnDomain(this.props.route.params.serverSettings.realm_uri );
310
315
} ;
311
316
312
317
handleAuth = async ( method : AuthenticationMethodDetails ) => {
@@ -331,7 +336,10 @@ class AuthScreenInner extends PureComponent<Props> {
331
336
< Centerer >
332
337
< RealmInfo
333
338
name = { serverSettings . realm_name }
334
- iconUrl = { new URL ( serverSettings . realm_icon , this . props . realm ) . toString ( ) }
339
+ iconUrl = { new URL (
340
+ serverSettings . realm_icon ,
341
+ this . props . route . params . serverSettings . realm_uri ,
342
+ ) . toString ( ) }
335
343
/>
336
344
{ activeAuthentications (
337
345
serverSettings . authentication_methods ,
@@ -363,10 +371,6 @@ class AuthScreenInner extends PureComponent<Props> {
363
371
}
364
372
}
365
373
366
- const AuthScreen : ComponentType < OuterProps > = connect((state, props) => ( {
367
- // Not from the Redux state, but it's convenient to validate the URL
368
- // in one central place, like here.
369
- realm : new URL ( props . route . params . serverSettings . realm_uri ) ,
370
- } ))(AuthScreenInner);
374
+ const AuthScreen : ComponentType < OuterProps > = connect< { || } , _ , _ > ()(AuthScreenInner);
371
375
372
376
export default AuthScreen;
0 commit comments