mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-04 02:36:59 +00:00
Fiexed long username bug when login
This commit is contained in:
parent
9466dc21dd
commit
1db310e480
@ -14,7 +14,7 @@ class AuthenticationForm(forms.Form):
|
|||||||
Base class for authenticating users. Extend this to get a form that accepts
|
Base class for authenticating users. Extend this to get a form that accepts
|
||||||
username/password logins.
|
username/password logins.
|
||||||
"""
|
"""
|
||||||
username = forms.CharField(label=_("Username"), max_length=30)
|
username = forms.CharField(label=_("Username"), max_length=255)
|
||||||
password = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
|
password = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
|
||||||
|
|
||||||
def __init__(self, request=None, *args, **kwargs):
|
def __init__(self, request=None, *args, **kwargs):
|
||||||
@ -55,7 +55,7 @@ class AuthenticationForm(forms.Form):
|
|||||||
return self.user_cache
|
return self.user_cache
|
||||||
|
|
||||||
class PasswordResetForm(forms.Form):
|
class PasswordResetForm(forms.Form):
|
||||||
email = forms.EmailField(label=_("E-mail"), max_length=75)
|
email = forms.EmailField(label=_("E-mail"), max_length=255)
|
||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
"""
|
"""
|
||||||
@ -96,6 +96,7 @@ class PasswordResetForm(forms.Form):
|
|||||||
'token': token_generator.make_token(user),
|
'token': token_generator.make_token(user),
|
||||||
'protocol': use_https and 'https' or 'http',
|
'protocol': use_https and 'https' or 'http',
|
||||||
}
|
}
|
||||||
|
|
||||||
send_mail(_("Password reset on %s") % site_name,
|
send_mail(_("Password reset on %s") % site_name,
|
||||||
t.render(Context(c)), None, [user.username])
|
t.render(Context(c)), None, [user.username])
|
||||||
|
|
||||||
|
@ -29,31 +29,14 @@ class RegistrationForm(forms.Form):
|
|||||||
registration backend.
|
registration backend.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
username = forms.RegexField(regex=r'^\w+$',
|
|
||||||
max_length=30,
|
|
||||||
widget=forms.TextInput(attrs=attrs_dict),
|
|
||||||
label=_("Username"),
|
|
||||||
error_messages={ 'invalid': _("This value must contain only letters, numbers and underscores.") })
|
|
||||||
email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
|
email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
|
||||||
maxlength=75)),
|
maxlength=225)),
|
||||||
label=_("Email address"))
|
label=_("Email address"))
|
||||||
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
|
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
|
||||||
label=_("Password"))
|
label=_("Password"))
|
||||||
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
|
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
|
||||||
label=_("Password (again)"))
|
label=_("Password (again)"))
|
||||||
|
|
||||||
def clean_username(self):
|
|
||||||
"""
|
|
||||||
Validate that the username is alphanumeric and is not already
|
|
||||||
in use.
|
|
||||||
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
user = User.objects.get(username__iexact=self.cleaned_data['username'])
|
|
||||||
except User.DoesNotExist:
|
|
||||||
return self.cleaned_data['username']
|
|
||||||
raise forms.ValidationError(_("A user with that username already exists."))
|
|
||||||
|
|
||||||
def clean_email(self):
|
def clean_email(self):
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(email__iexact=self.cleaned_data['email'])
|
user = User.objects.get(email__iexact=self.cleaned_data['email'])
|
||||||
|
Loading…
Reference in New Issue
Block a user