mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-15 16:04:01 +00:00
convert login id to email before authenticate
This commit is contained in:
parent
1be91b6887
commit
3fd6f0f68b
@ -12,7 +12,7 @@ from seahub.auth.tokens import default_token_generator
|
||||
from seahub.options.models import UserOptions
|
||||
from seahub.profile.models import Profile
|
||||
from seahub.utils import IS_EMAIL_CONFIGURED, send_html_email, \
|
||||
is_ldap_user, is_user_password_strong, get_site_name
|
||||
is_ldap_user, is_user_password_strong, get_site_name, is_valid_email
|
||||
|
||||
from captcha.fields import CaptchaField
|
||||
|
||||
@ -51,11 +51,16 @@ class AuthenticationForm(forms.Form):
|
||||
password = self.cleaned_data.get('password')
|
||||
|
||||
if username and password:
|
||||
|
||||
if not is_valid_email(username):
|
||||
# convert login id to username if any
|
||||
username = Profile.objects.convert_login_str_to_username(username)
|
||||
|
||||
self.user_cache = authenticate(username=username,
|
||||
password=password)
|
||||
if self.user_cache is None:
|
||||
"""then try login id/contact email/primary id"""
|
||||
# convert login id or contact email to username if any
|
||||
# convert contact email to username if any
|
||||
username = Profile.objects.convert_login_str_to_username(username)
|
||||
# convert username to primary id if any
|
||||
username = self.get_primary_id_by_username(username)
|
||||
|
Loading…
Reference in New Issue
Block a user