Skip to content

Commit 1ad763b

Browse files
authored
docs: Add warning in docs for for_user usage (#872)
1 parent c1231af commit 1ad763b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/creating_tokens_manually.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ Creating tokens manually
66
Sometimes, you may wish to manually create a token for a user. This could be
77
done as follows:
88

9+
.. warning::
10+
The ``for_user`` method does not check if the user is active. If you need to verify the user's status,
11+
this check needs to be done before creating the tokens.
12+
913
.. code-block:: python
1014
1115
from rest_framework_simplejwt.tokens import RefreshToken
16+
from rest_framework_simplejwt.exceptions import AuthenticationFailed
1217
1318
def get_tokens_for_user(user):
19+
if not user.is_active:
20+
raise AuthenticationFailed("User is not active")
21+
1422
refresh = RefreshToken.for_user(user)
1523
1624
return {

0 commit comments

Comments
 (0)