From 30e1784b294daeb426d885e9d4156d337cd801dc Mon Sep 17 00:00:00 2001 From: gzbender Date: Fri, 3 Aug 2018 22:16:36 +0500 Subject: [PATCH] =?UTF-8?q?LIL-600=20=D0=98=D0=B3=D0=BD=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B7=D0=B0=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D0=B2=D0=BD=D1=8B=D0=B5=20=D0=B1=D1=83=D0=BA=D0=B2=D1=8B?= =?UTF-8?q?=20=D0=B2=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/auth/forms.py | 8 +++++--- apps/auth/views.py | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/auth/forms.py b/apps/auth/forms.py index 0baea362..6977a3c2 100644 --- a/apps/auth/forms.py +++ b/apps/auth/forms.py @@ -1,4 +1,5 @@ from django import forms +from django.contrib.auth.forms import AuthenticationForm class LearnerRegistrationForm(forms.Form): @@ -8,6 +9,7 @@ class LearnerRegistrationForm(forms.Form): password = forms.CharField() -class LoginForm(forms.Form): - email = forms.CharField() - password = forms.CharField() +class AuthenticationForm(AuthenticationForm): + + def clean_username(self): + return self.cleaned_data.get('username', '').lower() diff --git a/apps/auth/views.py b/apps/auth/views.py index f6105e75..acb7712d 100644 --- a/apps/auth/views.py +++ b/apps/auth/views.py @@ -7,7 +7,6 @@ from facepy import GraphAPI from facepy.exceptions import FacepyError from django.contrib.auth import get_user_model, logout, login, views -from django.contrib.auth.forms import AuthenticationForm from django.core.files.base import ContentFile from django.http import JsonResponse from django.urls import reverse_lazy @@ -20,7 +19,7 @@ from django.shortcuts import redirect from apps.notification.utils import send_email from apps.config.models import Config -from .forms import LearnerRegistrationForm +from .forms import LearnerRegistrationForm, AuthenticationForm from .tokens import verification_email_token User = get_user_model() @@ -33,7 +32,7 @@ class LearnerRegistrationView(FormView): def form_valid(self, form): first_name = form.cleaned_data['first_name'] last_name = form.cleaned_data['last_name'] - email = form.cleaned_data['email'] + email = form.cleaned_data['email'].lower() password = form.cleaned_data['password'] user, created = User.objects.get_or_create( @@ -170,6 +169,7 @@ class FacebookLoginOrRegistration(View): "errors": {"email": 'is field required'} }) else: + email = email.lower() try: user = User.objects.get(email=email) except User.DoesNotExist: