fixed login

This commit is contained in:
Tomislav R 2016-03-07 19:25:01 +01:00
parent 2477fbc11b
commit 3ca9ef5900

View file

@ -3,6 +3,7 @@ from django.views.generic import View
from .models import CustomUser from .models import CustomUser
from .forms import LoginForm, RegisterForm from .forms import LoginForm, RegisterForm
from django.contrib.auth import authenticate,login
def validate_email(request, validate_slug): def validate_email(request, validate_slug):
@ -34,8 +35,9 @@ class LoginRegistrationView(View):
return render(request, 'templates/error.html') return render(request, 'templates/error.html')
elif email and password and not name: elif email and password and not name:
user = CustomUser.authenticate(email, password) user = authenticate(email=email, password=password)
if user: if user:
login(request,user)
return redirect('membership') return redirect('membership')
else: else:
return render(request, 'templates/login', {'msg': 'Wrong username or password'}) return render(request, 'templates/login', {'msg': 'Wrong username or password'})