1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-02 18:03:51 +00:00

Fiexed long username bug when login

This commit is contained in:
zhengxie 2012-10-15 19:09:53 +08:00
parent 9466dc21dd
commit 1db310e480
2 changed files with 4 additions and 20 deletions

View File

@ -14,7 +14,7 @@ class AuthenticationForm(forms.Form):
Base class for authenticating users. Extend this to get a form that accepts
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)
def __init__(self, request=None, *args, **kwargs):
@ -55,7 +55,7 @@ class AuthenticationForm(forms.Form):
return self.user_cache
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):
"""
@ -96,6 +96,7 @@ class PasswordResetForm(forms.Form):
'token': token_generator.make_token(user),
'protocol': use_https and 'https' or 'http',
}
send_mail(_("Password reset on %s") % site_name,
t.render(Context(c)), None, [user.username])

View File

@ -29,31 +29,14 @@ class RegistrationForm(forms.Form):
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,
maxlength=75)),
maxlength=225)),
label=_("Email address"))
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
label=_("Password"))
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
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):
try:
user = User.objects.get(email__iexact=self.cleaned_data['email'])