Created
June 3, 2013 08:33
-
-
Save introom/5696868 to your computer and use it in GitHub Desktop.
Audiu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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