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)