You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
484 B
14 lines
484 B
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
|