mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	backends: Remove assumption that only one user can have a given email.
I probably should have just done this in the original implementation; there's only a small downside in the form of an extra database query when trying to authenticate a user who doesn't exist.
This commit is contained in:
		@@ -20,8 +20,7 @@ from zerver.lib.request import JsonableError
 | 
			
		||||
from zerver.lib.subdomains import user_matches_subdomain, get_subdomain
 | 
			
		||||
from zerver.lib.users import check_full_name
 | 
			
		||||
from zerver.models import UserProfile, Realm, get_user_profile_by_id, \
 | 
			
		||||
    get_user_profile_by_email, remote_user_to_email, email_to_username, \
 | 
			
		||||
    get_realm, get_user
 | 
			
		||||
    remote_user_to_email, email_to_username, get_realm, get_user
 | 
			
		||||
 | 
			
		||||
def pad_method_dict(method_dict):
 | 
			
		||||
    # type: (Dict[Text, bool]) -> Dict[Text, bool]
 | 
			
		||||
@@ -94,9 +93,7 @@ def common_get_active_user(email: str, realm: Realm,
 | 
			
		||||
        # check whether they might have an account in another realm,
 | 
			
		||||
        # and if so, provide a helpful error message via
 | 
			
		||||
        # `invalid_subdomain`.
 | 
			
		||||
        try:
 | 
			
		||||
            user_profile = get_user_profile_by_email(email)
 | 
			
		||||
        except UserProfile.DoesNotExist:
 | 
			
		||||
        if not UserProfile.objects.filter(email__iexact=email).exists():
 | 
			
		||||
            return None
 | 
			
		||||
        if return_data is not None:
 | 
			
		||||
            return_data['invalid_subdomain'] = True
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user