def __call__(self, f):
        def wrapped_f(request, *pargs, **kwargs):
            from django.http import HttpResponseForbidden
            self.f = f
            if 'HTTP_X_AUTH_TOKEN' in request.META:
                self.token_string = request.META['HTTP_X_AUTH_TOKEN']
                if self.valid_token():
                    user = self.fetch_user()
                    if user is None:  # The user matching the token has been deleted
                        return HttpResponseBadRequest("Could not obtain user information")
                    if (self.required_role is not None) and (self.required_role not in user['roles']):
                        return HttpResponseForbidden()
                    request.user = user
                    request.token_string = self.token_string
                    return self.f(request, *pargs, **kwargs)

            # 401 Unauthorized if you reach this point
            return HttpResponse(status=401)
        return wrapped_f
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/api/models/auth.py/RequireLogin.__call__/original