Merge branch 'release/0.2.21'
This commit is contained in:
commit
5717a10402
2 changed files with 18 additions and 4 deletions
20
account/forms.py
Normal file → Executable file
20
account/forms.py
Normal file → Executable file
|
|
@ -7,12 +7,26 @@ from django import forms
|
|||
from django.contrib.auth import authenticate
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
class UsernameField(forms.CharField):
|
||||
"""
|
||||
The username field makes sure that usernames are always entered in lower-case.
|
||||
If we do not convert the username to lower-case, Django will create more than
|
||||
one user object in the database. If we then try to login again, the Django auth
|
||||
subsystem will do an query that looks like this: username__iexact="username". The
|
||||
result is an error, because iexact returns the objects for "username" and "Username".
|
||||
"""
|
||||
|
||||
def to_python(self, value):
|
||||
value = super(UsernameField, self).to_python(value)
|
||||
value = value.lower()
|
||||
return value
|
||||
|
||||
|
||||
class LoginForm(forms.Form):
|
||||
username = forms.CharField(max_length=255)
|
||||
username = UsernameField(max_length=255)
|
||||
password = forms.CharField(max_length=255, widget=forms.PasswordInput,
|
||||
help_text=_('Cookies must be enabled.'))
|
||||
|
||||
|
||||
def clean(self):
|
||||
username = self.cleaned_data.get('username')
|
||||
password = self.cleaned_data.get('password')
|
||||
|
|
@ -79,7 +93,7 @@ class PasswordForm(forms.Form):
|
|||
def clean(self):
|
||||
cleaned_data = super(PasswordForm, self).clean()
|
||||
old_password = cleaned_data.get('old_password')
|
||||
username = self._request.user.username
|
||||
username = self._request.user.username.lower()
|
||||
user = authenticate(username=username, password=old_password)
|
||||
|
||||
if not user or not user.is_active:
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ msgstr "c-lab-PIN"
|
|||
|
||||
#: templates/clabpin.html:8
|
||||
msgid "Change your c-lab PIN to access the c-lab in the basement."
|
||||
msgstr "PIN ändern für den Zugang um c-lab im Keller."
|
||||
msgstr "PIN ändern für den Zugang zum c-lab im Keller."
|
||||
|
||||
#: templates/gastropin.html:5
|
||||
msgid "Gastro PIN"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue