Skip to content

Instantly share code, notes, and snippets.

@introom
Created June 3, 2013 08:33
Show Gist options
  • Save introom/5696868 to your computer and use it in GitHub Desktop.
Save introom/5696868 to your computer and use it in GitHub Desktop.
Audiu
class NoCSRFLoginView(View):
def get(self, request):
return HttpResponse("Please post your info.")
@never_cache
def post(self, request, authentication_form=AuthenticationForm):
form = authentication_form(data=request.POST)
if form.is_valid():
# Okay, security check complete. Log the user in.
auth_login(request, form.get_user())
if request.session.test_cookie_worked():
request.session.delete_test_cookie()
return HttpResponse("ok")
return HttpResponse("failed")
url(r'^nocsrf_login', csrf_exempt(NoCSRFLoginView.as_view())),
@introom
Copy link
Author

introom commented Jun 3, 2013

from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from django.views.decorators.cache import never_cache
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import login as auth_login
from django.http.response import HttpResponse

some imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment