-
-
Save pedrohsbarbosa99/8e42e54466ef62e0ba439d5177d99db7 to your computer and use it in GitHub Desktop.
This file contains 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 import Schema | |
from ninja.router import Router | |
from ninja_jwt.schema import ( | |
TokenObtainPairInputSchema, | |
TokenObtainPairOutputSchema, | |
TokenRefreshInputSchema, | |
TokenRefreshOutputSchema, | |
TokenVerifyInputSchema, | |
) | |
auth_router = Router() | |
@auth_router.post( | |
"/pair", response=TokenObtainPairOutputSchema, url_name="token_obtain_pair" | |
) | |
def obtain_token(request, user_token: TokenObtainPairInputSchema): | |
user_token.check_user_authentication_rule() | |
return user_token.output_schema() | |
@auth_router.post( | |
"/refresh", | |
response=TokenRefreshOutputSchema, | |
url_name="token_refresh", | |
auth=None, | |
) | |
def refresh_token(request, refresh_token: TokenRefreshInputSchema): | |
return refresh_token.to_response_schema() | |
@auth_router.post( | |
"/verify", | |
response={200: Schema}, | |
url_name="token_verify", | |
) | |
def verify_token(request, token: TokenVerifyInputSchema): | |
return token.to_response_schema() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment