Ensure CSRF cookie is set. Updated dev version

This commit is contained in:
Syrus Akbary 2016-09-19 23:14:59 -07:00
parent d05407f6a5
commit 317c8ceec4
2 changed files with 4 additions and 1 deletions

View File

@ -6,7 +6,9 @@ import six
from django.http import HttpResponse, HttpResponseNotAllowed from django.http import HttpResponse, HttpResponseNotAllowed
from django.http.response import HttpResponseBadRequest from django.http.response import HttpResponseBadRequest
from django.shortcuts import render from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views.generic import View from django.views.generic import View
from django.views.decorators.csrf import ensure_csrf_cookie
from graphql import Source, execute, parse, validate from graphql import Source, execute, parse, validate
from graphql.error import format_error as format_graphql_error from graphql.error import format_error as format_graphql_error
@ -89,6 +91,7 @@ class GraphQLView(View):
def get_context(self, request): def get_context(self, request):
return request return request
@method_decorator(ensure_csrf_cookie)
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
try: try:
if request.method.lower() not in ('get', 'post'): if request.method.lower() not in ('get', 'post'):

View File

@ -2,7 +2,7 @@ from setuptools import find_packages, setup
setup( setup(
name='graphene-django', name='graphene-django',
version='1.0.dev20160919000002', version='1.0.dev20160919000003',
description='Graphene Django integration', description='Graphene Django integration',
long_description=open('README.rst').read(), long_description=open('README.rst').read(),