@@ -179,28 +179,22 @@ impl AuthorizationGrant {
179179 ///
180180 /// Returns `LoginHint::MXID` for valid mxid 'mxid:@john.doe:example.com'
181181 ///
182- /// Returns `LoginHint::Email` for valid email '[email protected] ' if 183- /// email supports is enabled
182+ /// Returns `LoginHint::Email` for valid email '[email protected] ' 184183 ///
185184 /// Otherwise returns `LoginHint::None`
186185 #[ 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 {
188187 let Some ( login_hint) = & self . login_hint else {
189188 return LoginHint :: None ;
190189 } ;
191190
192191 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) ;
204198 } ;
205199
206200 match prefix {
@@ -308,7 +302,7 @@ mod tests {
308302 ..AuthorizationGrant :: sample ( now, & mut rng)
309303 } ;
310304
311- let hint = grant. parse_login_hint ( "example.com" , false ) ;
305+ let hint = grant. parse_login_hint ( "example.com" ) ;
312306
313307 assert ! ( matches!( hint, LoginHint :: None ) ) ;
314308 }
@@ -326,7 +320,7 @@ mod tests {
326320 ..AuthorizationGrant :: sample ( now, & mut rng)
327321 } ;
328322
329- let hint = grant. parse_login_hint ( "example.com" , false ) ;
323+ let hint = grant. parse_login_hint ( "example.com" ) ;
330324
331325 assert ! ( matches!( hint, LoginHint :: MXID ( mxid) if mxid. localpart( ) == "example-user" ) ) ;
332326 }
@@ -344,29 +338,11 @@ mod tests {
344338 ..AuthorizationGrant :: sample ( now, & mut rng)
345339 } ;
346340
347- let hint = grant. parse_login_hint ( "example.com" , true ) ;
341+ let hint = grant. parse_login_hint ( "example.com" ) ;
348342
349343 assert ! ( matches!( hint, LoginHint :: Email ( email) if email. to_string( ) == "example@user" ) ) ;
350344 }
351345
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-
370346 #[ test]
371347 fn invalid_login_hint ( ) {
372348 #[ allow( clippy:: disallowed_methods) ]
@@ -380,7 +356,7 @@ mod tests {
380356 ..AuthorizationGrant :: sample ( now, & mut rng)
381357 } ;
382358
383- let hint = grant. parse_login_hint ( "example.com" , false ) ;
359+ let hint = grant. parse_login_hint ( "example.com" ) ;
384360
385361 assert ! ( matches!( hint, LoginHint :: None ) ) ;
386362 }
@@ -398,7 +374,7 @@ mod tests {
398374 ..AuthorizationGrant :: sample ( now, & mut rng)
399375 } ;
400376
401- let hint = grant. parse_login_hint ( "example.com" , false ) ;
377+ let hint = grant. parse_login_hint ( "example.com" ) ;
402378
403379 assert ! ( matches!( hint, LoginHint :: None ) ) ;
404380 }
@@ -416,7 +392,7 @@ mod tests {
416392 ..AuthorizationGrant :: sample ( now, & mut rng)
417393 } ;
418394
419- let hint = grant. parse_login_hint ( "example.com" , false ) ;
395+ let hint = grant. parse_login_hint ( "example.com" ) ;
420396
421397 assert ! ( matches!( hint, LoginHint :: None ) ) ;
422398 }
0 commit comments