Commit b2df8fbf authored by Skia's avatar Skia
Browse files

Fix LoginForm

parent 3239a2e4
Pipeline #169 failed with stage
in 1 minute and 43 seconds
...@@ -75,14 +75,15 @@ class LoginForm(AuthenticationForm): ...@@ -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]$")
if account_code.match(data['username']): try:
user = Customer.objects.filter(account_id=data['username']).first().user if account_code.match(data['username']):
elif '@' in data['username']: user = Customer.objects.filter(account_id__iexact=data['username']).first().user
user = User.objects.filter(email=data['username']).first() elif '@' in data['username']:
else: user = User.objects.filter(email__iexact=data['username']).first()
user = User.objects.filter(username=data['username']).first() else:
if user: user = User.objects.filter(username=data['username']).first()
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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment