Skip to content

Instantly share code, notes, and snippets.

@allieus
Created August 13, 2011 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allieus/1143585 to your computer and use it in GitHub Desktop.
Save allieus/1143585 to your computer and use it in GitHub Desktop.
django decorator : logged user are denied
from django.http import HttpResponseForbidden
from django.contrib.auth.models import AnonymousUser
from django.shortcuts import redirect
def deny_logged_user(fn):
def wrap(request, *args, **kwargs):
# if isinstance(request.user, AnonymousUser):
if request.user.is_authenticated():
return fn(request, *args, **kwargs)
# TODO for logged user
# return redirect('/')
return wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment