Created
May 20, 2024 13:18
-
-
Save gabigab117/9eb974267d552350754a73299a016a68 to your computer and use it in GitHub Desktop.
SuperUserAuth Ninja JWT
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 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