From 943b70e9b00396dcbd5965a424645fd9fca1559b Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 19 Jan 2024 13:52:27 +0700 Subject: [PATCH] Fix dj rest auth response jwt with expiration --- drf_spectacular/contrib/rest_auth.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drf_spectacular/contrib/rest_auth.py b/drf_spectacular/contrib/rest_auth.py index df9305bb..fc7fbc62 100644 --- a/drf_spectacular/contrib/rest_auth.py +++ b/drf_spectacular/contrib/rest_auth.py @@ -28,13 +28,18 @@ def get_token_serializer_class(): if get_version_tuple(__version__) < (3, 0, 0): use_jwt = getattr(settings, 'REST_USE_JWT', False) + jwt_return_expiration = False else: from dj_rest_auth.app_settings import api_settings use_jwt = api_settings.USE_JWT + jwt_return_expiration = api_settings.JWT_AUTH_RETURN_EXPIRATION if use_jwt: - return get_dj_rest_auth_setting('JWTSerializer', 'JWT_SERIALIZER') + if jwt_return_expiration: + return get_dj_rest_auth_setting('JWTSerializer', 'JWT_SERIALIZER_WITH_EXPIRATION') + else: + return get_dj_rest_auth_setting('JWTSerializer', 'JWT_SERIALIZER') else: return get_dj_rest_auth_setting('TokenSerializer', 'TOKEN_SERIALIZER')