Skip to content

Instantly share code, notes, and snippets.

@osa1
Created March 5, 2012 09:40
Show Gist options
  • Save osa1/1977648 to your computer and use it in GitHub Desktop.
Save osa1/1977648 to your computer and use it in GitHub Desktop.
authentication decorator
def requires_authentication(f):
def df(request):
json_response = {"result": "fail"}
if request.user.is_authenticated and request.user.is_active:
json_response.update(f(request))
return HttpResponse(json.dumps(json_response), mimetype="application/json")
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment