mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
Fix LoginForm
This commit is contained in:
parent
3239a2e481
commit
b2df8fbf18
@ -75,14 +75,15 @@ class LoginForm(AuthenticationForm):
|
|||||||
from counter.models import Customer
|
from counter.models import Customer
|
||||||
data = kwargs['data'].copy()
|
data = kwargs['data'].copy()
|
||||||
account_code = re.compile(r"^[0-9]+[A-Za-z]$")
|
account_code = re.compile(r"^[0-9]+[A-Za-z]$")
|
||||||
|
try:
|
||||||
if account_code.match(data['username']):
|
if account_code.match(data['username']):
|
||||||
user = Customer.objects.filter(account_id=data['username']).first().user
|
user = Customer.objects.filter(account_id__iexact=data['username']).first().user
|
||||||
elif '@' in data['username']:
|
elif '@' in data['username']:
|
||||||
user = User.objects.filter(email=data['username']).first()
|
user = User.objects.filter(email__iexact=data['username']).first()
|
||||||
else:
|
else:
|
||||||
user = User.objects.filter(username=data['username']).first()
|
user = User.objects.filter(username=data['username']).first()
|
||||||
if user:
|
|
||||||
data['username'] = user.username
|
data['username'] = user.username
|
||||||
|
except: pass
|
||||||
kwargs['data'] = data
|
kwargs['data'] = data
|
||||||
super(LoginForm, self).__init__(*arg, **kwargs)
|
super(LoginForm, self).__init__(*arg, **kwargs)
|
||||||
self.fields['username'].label = _("Username, email, or account number")
|
self.fields['username'].label = _("Username, email, or account number")
|
||||||
|
Loading…
Reference in New Issue
Block a user