Merge pull request #664 from mouse-reeve/login-csrf

Fixes csrf failure logging on from multiple tabs
This commit is contained in:
Mouse Reeve 2021-02-28 16:16:00 -08:00 committed by GitHub
commit b2779cc6bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views import View
from bookwyrm import forms, models
@ -13,6 +14,7 @@ from bookwyrm.settings import DOMAIN
# pylint: disable= no-self-use
@method_decorator(csrf_exempt, name='dispatch')
class Login(View):
''' authenticate an existing user '''
def get(self, request):
@ -28,6 +30,8 @@ class Login(View):
def post(self, request):
''' authentication action '''
if request.user.is_authenticated:
return redirect('/')
login_form = forms.LoginForm(request.POST)
localname = login_form.data['localname']