예제 #1
0
 def dec(request, *args, **kwargs):
     if request.user.is_authenticated():
         roles = set([role['name'].lower() for role in request.user.roles])
         # set operator <= tests that all members of set 1 are in set 2
         if view_func._required_roles <= set(roles):
             return view_func(request, *args, **kwargs)
     raise NotAuthorized("You are not authorized to access %s" %
                         request.path)
예제 #2
0
 def dec(request, *args, **kwargs):
     if request.user.is_authenticated():
         if request.user.has_perms(view_func._required_perms):
             return view_func(request, *args, **kwargs)
     raise NotAuthorized(
         _("You are not authorized to access %s") % request.path)
예제 #3
0
    def dec(request, *args, **kwargs):
        if not component.can_access({'request': request}):
            raise NotAuthorized(
                _("You are not authorized to access %s") % request.path)

        return view_func(request, *args, **kwargs)