mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	admin: Added realm option to prevent users from changing their email.
A realm option to prevent users from changing their email address is added. Fixes #3777.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							d25bfb88d3
						
					
				
				
					commit
					cd2d798498
				
			@@ -38,6 +38,10 @@ from confirmation.models import EmailChangeConfirmation
 | 
			
		||||
@zulip_login_required
 | 
			
		||||
def confirm_email_change(request, confirmation_key):
 | 
			
		||||
    # type: (HttpRequest, str) -> HttpResponse
 | 
			
		||||
    user_profile = request.user
 | 
			
		||||
    if user_profile.realm.email_changes_disabled:
 | 
			
		||||
        raise JsonableError(_("Email change disabled"))
 | 
			
		||||
 | 
			
		||||
    confirmation_key = confirmation_key.lower()
 | 
			
		||||
    obj = EmailChangeConfirmation.objects.confirm(confirmation_key)
 | 
			
		||||
    confirmed = False
 | 
			
		||||
@@ -128,6 +132,8 @@ def json_change_settings(request, user_profile,
 | 
			
		||||
    result = {}
 | 
			
		||||
    new_email = email.strip()
 | 
			
		||||
    if user_profile.email != email and new_email != '':
 | 
			
		||||
        if user_profile.realm.email_changes_disabled:
 | 
			
		||||
            return json_error(_("Email change is disabled!"))
 | 
			
		||||
        error, skipped = validate_email(user_profile, new_email)
 | 
			
		||||
        if error or skipped:
 | 
			
		||||
            return json_error(error or skipped)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user