Closed OmarSRolo closed 7 months ago
Hi @OmarSRolo, async def accept(self, request)
is an async function so your decorator should be implemented as follows:
def user_permission(permission: str, status: int = 403):
def int_permission(func):
async def function(self, request, **kwargs):
if permission == "superuser" and not request.user.is_superuser:
return Response([_("You don't have access to the resource")], status=status)
if not request.user.has_perm(permission):
return Response([_("You don't have access to the resource")], status=status)
return await func(self, request, **kwargs)
return function
return int_permission
Let me know if it solves your problem!
I am using this ViewSet:
And the error is: