Created
August 13, 2011 07:49
-
-
Save allieus/1143585 to your computer and use it in GitHub Desktop.
django decorator : logged user are denied
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
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