Add form_valid to the index form

This commit is contained in:
PCoder 2019-02-23 09:20:58 +01:00
parent 76c585cdf4
commit 5c96f5c186
1 changed files with 10 additions and 0 deletions

View File

@ -100,6 +100,16 @@ class LDAP(object):
class Index(FormView):
template_name = "landing.html"
form_class = LoginForm
success_url = 'useroptions.html'
def form_valid(self, form):
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
user = authenticate(username=email, password=password)
if user is not None:
login(self.request, user)
return render(self.request, 'useroptions.html', { 'user': user } )
return render(self.request, 'loginfailed.html')
class Register(View):
def get(self, request):