@@ -179,28 +179,22 @@ impl AuthorizationGrant {
179
179
///
180
180
/// Returns `LoginHint::MXID` for valid mxid 'mxid:@john.doe:example.com'
181
181
///
182
- /// Returns `LoginHint::Email` for valid email '[email protected] ' if
183
- /// email supports is enabled
182
+ /// Returns `LoginHint::Email` for valid email '[email protected] '
184
183
///
185
184
/// Otherwise returns `LoginHint::None`
186
185
#[ must_use]
187
- pub fn parse_login_hint ( & self , homeserver : & str , login_with_email_allowed : bool ) -> LoginHint {
186
+ pub fn parse_login_hint ( & self , homeserver : & str ) -> LoginHint {
188
187
let Some ( login_hint) = & self . login_hint else {
189
188
return LoginHint :: None ;
190
189
} ;
191
190
192
191
let Some ( ( prefix, value) ) = login_hint. split_once ( ':' ) else {
193
- // If email supports for login_hint is enabled
194
- if login_with_email_allowed {
195
- // Validate the email
196
- let Ok ( address) = lettre:: Address :: from_str ( login_hint) else {
197
- // Return none if the format is incorrect
198
- return LoginHint :: None ;
199
- } ;
200
- return LoginHint :: Email ( address) ;
201
- }
202
- // Unknown hint type, treat as none
203
- return LoginHint :: None ;
192
+ // Validate the email
193
+ let Ok ( address) = lettre:: Address :: from_str ( login_hint) else {
194
+ // Return none if the format is incorrect
195
+ return LoginHint :: None ;
196
+ } ;
197
+ return LoginHint :: Email ( address) ;
204
198
} ;
205
199
206
200
match prefix {
@@ -308,7 +302,7 @@ mod tests {
308
302
..AuthorizationGrant :: sample ( now, & mut rng)
309
303
} ;
310
304
311
- let hint = grant. parse_login_hint ( "example.com" , false ) ;
305
+ let hint = grant. parse_login_hint ( "example.com" ) ;
312
306
313
307
assert ! ( matches!( hint, LoginHint :: None ) ) ;
314
308
}
@@ -326,7 +320,7 @@ mod tests {
326
320
..AuthorizationGrant :: sample ( now, & mut rng)
327
321
} ;
328
322
329
- let hint = grant. parse_login_hint ( "example.com" , false ) ;
323
+ let hint = grant. parse_login_hint ( "example.com" ) ;
330
324
331
325
assert ! ( matches!( hint, LoginHint :: MXID ( mxid) if mxid. localpart( ) == "example-user" ) ) ;
332
326
}
@@ -344,29 +338,11 @@ mod tests {
344
338
..AuthorizationGrant :: sample ( now, & mut rng)
345
339
} ;
346
340
347
- let hint = grant. parse_login_hint ( "example.com" , true ) ;
341
+ let hint = grant. parse_login_hint ( "example.com" ) ;
348
342
349
343
assert ! ( matches!( hint, LoginHint :: Email ( email) if email. to_string( ) == "example@user" ) ) ;
350
344
}
351
345
352
- #[ test]
353
- fn valid_login_hint_with_email_when_login_with_email_not_allowed ( ) {
354
- #[ allow( clippy:: disallowed_methods) ]
355
- let mut rng = thread_rng ( ) ;
356
-
357
- #[ allow( clippy:: disallowed_methods) ]
358
- let now = Utc :: now ( ) ;
359
-
360
- let grant = AuthorizationGrant {
361
- login_hint : Some ( String :: from ( "example@user" ) ) ,
362
- ..AuthorizationGrant :: sample ( now, & mut rng)
363
- } ;
364
-
365
- let hint = grant. parse_login_hint ( "example.com" , false ) ;
366
-
367
- assert ! ( matches!( hint, LoginHint :: None ) ) ;
368
- }
369
-
370
346
#[ test]
371
347
fn invalid_login_hint ( ) {
372
348
#[ allow( clippy:: disallowed_methods) ]
@@ -380,7 +356,7 @@ mod tests {
380
356
..AuthorizationGrant :: sample ( now, & mut rng)
381
357
} ;
382
358
383
- let hint = grant. parse_login_hint ( "example.com" , false ) ;
359
+ let hint = grant. parse_login_hint ( "example.com" ) ;
384
360
385
361
assert ! ( matches!( hint, LoginHint :: None ) ) ;
386
362
}
@@ -398,7 +374,7 @@ mod tests {
398
374
..AuthorizationGrant :: sample ( now, & mut rng)
399
375
} ;
400
376
401
- let hint = grant. parse_login_hint ( "example.com" , false ) ;
377
+ let hint = grant. parse_login_hint ( "example.com" ) ;
402
378
403
379
assert ! ( matches!( hint, LoginHint :: None ) ) ;
404
380
}
@@ -416,7 +392,7 @@ mod tests {
416
392
..AuthorizationGrant :: sample ( now, & mut rng)
417
393
} ;
418
394
419
- let hint = grant. parse_login_hint ( "example.com" , false ) ;
395
+ let hint = grant. parse_login_hint ( "example.com" ) ;
420
396
421
397
assert ! ( matches!( hint, LoginHint :: None ) ) ;
422
398
}
0 commit comments