Created
December 10, 2019 16:21
-
-
Save aballah-chamakh/3403241b6ca97ddfb63788139e25e103 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 rest_framework import permissions | |
class IsAuthenticatedAndOwnerOrDeny(permissions.BasePermission): | |
def has_permission(self, request, view): | |
# check if the user is authenticated | |
return self.request.user.is_authenticated() | |
def has_object_permission(self, request, view, obj): | |
# check if the user is the owner of the inference object | |
return obj.user == request.user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment