mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Fix bug in dev login which showed email/password prompts on logins after the first.
(imported from commit 626684ef1da8feb53aca05c9225ee628156f9810)
This commit is contained in:
		@@ -5,10 +5,7 @@ import ujson
 | 
				
			|||||||
from zproject.backends import password_auth_enabled, dev_auth_enabled, google_auth_enabled
 | 
					from zproject.backends import password_auth_enabled, dev_auth_enabled, google_auth_enabled
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def add_settings(request):
 | 
					def add_settings(request):
 | 
				
			||||||
    if hasattr(request.user, "realm"):
 | 
					    realm = request.user.realm if hasattr(request.user, "realm") else None
 | 
				
			||||||
        is_pw_auth_enabled = password_auth_enabled(request.user.realm)
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        is_pw_auth_enabled = True
 | 
					 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        'full_navbar':   settings.FULL_NAVBAR,
 | 
					        'full_navbar':   settings.FULL_NAVBAR,
 | 
				
			||||||
        # We use the not_enterprise variable name so that templates
 | 
					        # We use the not_enterprise variable name so that templates
 | 
				
			||||||
@@ -24,7 +21,7 @@ def add_settings(request):
 | 
				
			|||||||
        'api_site_required': settings.EXTERNAL_API_PATH != "api.zulip.com",
 | 
					        'api_site_required': settings.EXTERNAL_API_PATH != "api.zulip.com",
 | 
				
			||||||
        'email_integration_enabled': settings.EMAIL_GATEWAY_BOT != "",
 | 
					        'email_integration_enabled': settings.EMAIL_GATEWAY_BOT != "",
 | 
				
			||||||
        'email_gateway_example': settings.EMAIL_GATEWAY_EXAMPLE,
 | 
					        'email_gateway_example': settings.EMAIL_GATEWAY_EXAMPLE,
 | 
				
			||||||
        'password_auth_enabled': is_pw_auth_enabled,
 | 
					        'password_auth_enabled': password_auth_enabled(realm),
 | 
				
			||||||
        'dev_auth_enabled': dev_auth_enabled(),
 | 
					        'dev_auth_enabled': dev_auth_enabled(),
 | 
				
			||||||
        'google_auth_enabled': google_auth_enabled(),
 | 
					        'google_auth_enabled': google_auth_enabled(),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,12 +14,13 @@ from apiclient.sample_tools import client as googleapiclient
 | 
				
			|||||||
from oauth2client.crypt import AppIdentityError
 | 
					from oauth2client.crypt import AppIdentityError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def password_auth_enabled(realm):
 | 
					def password_auth_enabled(realm):
 | 
				
			||||||
    if realm.domain == 'employees.customer16.invalid':
 | 
					    if realm is not None:
 | 
				
			||||||
        return False
 | 
					        if realm.domain == 'employees.customer16.invalid':
 | 
				
			||||||
    elif realm.domain == 'zulip.com' and settings.DEPLOYED:
 | 
					            return False
 | 
				
			||||||
        # the dropbox realm is SSO only, but the unit tests still need to be
 | 
					        elif realm.domain == 'zulip.com' and settings.DEPLOYED:
 | 
				
			||||||
        # able to login
 | 
					            # the dropbox realm is SSO only, but the unit tests still need to be
 | 
				
			||||||
        return False
 | 
					            # able to login
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for backend in django.contrib.auth.get_backends():
 | 
					    for backend in django.contrib.auth.get_backends():
 | 
				
			||||||
         if isinstance(backend, EmailAuthBackend):
 | 
					         if isinstance(backend, EmailAuthBackend):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user