2022-06-24 17:08:58 +00:00
|
|
|
"""GraphQL API for SelfPrivacy."""
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
import typing
|
|
|
|
from strawberry.permission import BasePermission
|
|
|
|
from strawberry.types import Info
|
|
|
|
|
|
|
|
from selfprivacy_api.utils.auth import is_token_valid
|
|
|
|
|
2022-06-24 18:14:20 +00:00
|
|
|
|
2022-06-24 17:08:58 +00:00
|
|
|
class IsAuthenticated(BasePermission):
|
|
|
|
"""Is authenticated permission"""
|
2022-06-24 18:14:20 +00:00
|
|
|
|
2022-06-24 17:08:58 +00:00
|
|
|
message = "You must be authenticated to access this resource."
|
|
|
|
|
|
|
|
def has_permission(self, source: typing.Any, info: Info, **kwargs) -> bool:
|
2022-08-10 23:36:36 +00:00
|
|
|
return info.context.is_authenticated
|