예제 #1
0
 def can_render(self, context):
     try:
         return self._visible_to(context['request'].user)
     except KeyError:
         try:
             return self._visible_to(context['viewer'])
         except KeyError:
             return self._visible_to(AnonymousUser())
예제 #2
0
    def process_request(self, request):
        super(ExtendedUser, self).process_request(request)
        if request.user.is_authenticated():
            try:
                request.user = request.user.user
                return None
            except:
                pass

        request.user = AnonymousUser()
        return None
예제 #3
0
class ExtendedUser(AuthenticationMiddleware):
    def process_request(self, request):
        super(ExtendedUser, self).process_request(request)
        if request.user.is_authenticated():
            try:
                request.user = request.user.user

                if request.user.is_suspended():
                    user = request.user
                    logout(request)
                    return forward_suspended_user(request, user)

                return None
            except Exception, e:
                import traceback
                logging.error(
                    "Unable to convert auth_user %s to forum_user: \n%s" %
                    (request.user.id, traceback.format_exc()))

        request.user = AnonymousUser()
        return None
예제 #4
0
 def __call__(self, context):
     if callable(self.argument):
         user = context.get('request', None) and context['request'].user or AnonymousUser()
         return self.argument(user, context)
     else:
         return self.argument