ldap: Prevent useless password resets when email auth is not enabled.

While the passwords wouldn't do anything without email auth enabled
anyway, it's probably better not to have users be able to go through
the flow.
This commit is contained in:
Tim Abbott
2017-10-24 11:44:01 -07:00
parent b590cd6c8f
commit d69c39cad1
2 changed files with 21 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ from zerver.lib.subdomains import get_subdomain, check_subdomain, is_root_domain
from zerver.lib.users import check_full_name
from zerver.models import Realm, get_user_profile_by_email, UserProfile, \
get_realm, email_to_domain, email_allowed_for_realm
from zproject.backends import password_auth_enabled
from zproject.backends import email_auth_enabled
import logging
import re
@@ -191,7 +191,7 @@ class ZulipPasswordResetForm(PasswordResetForm):
users who don't have a usable password to reset their
passwords.
"""
if not password_auth_enabled:
if not email_auth_enabled():
logging.info("Password reset attempted for %s even though password auth is disabled." % (email,))
return []
result = UserProfile.objects.filter(email__iexact=email, is_active=True,