From 71fabdfd717cac6b56d41dd8aa59acb441cfeb02 Mon Sep 17 00:00:00 2001 From: RDxR10 Date: Thu, 10 Oct 2024 01:57:25 +0530 Subject: [PATCH] Update tokens.py Fix for Issue #815 --- rest_framework_simplejwt/tokens.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_framework_simplejwt/tokens.py b/rest_framework_simplejwt/tokens.py index 9e9c3b9df..0105df094 100644 --- a/rest_framework_simplejwt/tokens.py +++ b/rest_framework_simplejwt/tokens.py @@ -202,6 +202,8 @@ def for_user(cls: Type[T], user: AuthUser) -> T: Returns an authorization token for the given user that will be provided after authenticating the user's credentials. """ + if not user.is_active: + raise Exception("User is inactive.") user_id = getattr(user, api_settings.USER_ID_FIELD) if not isinstance(user_id, int): user_id = str(user_id)