Skip to content

Instantly share code, notes, and snippets.

@gabigab117
Created May 20, 2024 13:18
Show Gist options
  • Save gabigab117/9eb974267d552350754a73299a016a68 to your computer and use it in GitHub Desktop.
Save gabigab117/9eb974267d552350754a73299a016a68 to your computer and use it in GitHub Desktop.
SuperUserAuth Ninja JWT
from ninja_jwt.authentication import JWTAuth
from ninja_jwt.exceptions import AuthenticationFailed
class SuperUserAuth(JWTAuth):
def get_user(self, validated_token):
user = super().get_user(validated_token)
if not user.is_superuser:
raise AuthenticationFailed("L'utilisateur n'est pas un super utilisateur")
return user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment