from rest_framework.permissions import BasePermission class IsTokenAuthenticatedOrAnonymous(BasePermission): """ Allow access to token-authenticated users OR anonymous users. Useful for guest token endpoints. """ def has_permission(self, request, view): # Allow if user is authenticated (including token users) if request.user and request.user.is_authenticated: return True # Allow anonymous access return True