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):
from counter.models import Customer
data = kwargs['data'].copy()
account_code = re.compile(r"^[0-9]+[A-Za-z]$")
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']:
user = User.objects.filter(email=data['username']).first()
user = User.objects.filter(email__iexact=data['username']).first()
user = User.objects.filter(username=data['username']).first()
if user:
data['username'] = user.username
except: pass
kwargs['data'] = data
super(LoginForm, self).__init__(*arg, **kwargs)
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