Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Added JWT_PAYLOAD_HANDLER usage example to the docs #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ Default is `datetime.timedelta(days=7)` (7 days).
### JWT_PAYLOAD_HANDLER
Specify a custom function to generate the token payload

Example:
```
from rest_framework_jwt.utils import jwt_payload_handler

def jwt_custom_payload_handler(user):
payload = jwt_payload_handler(user)
payload['role'] = 'xyz'
return payload

# settings.py
JWT_AUTH['JWT_PAYLOAD_HANDLER'] = 'path.to.your.jwt_custom_payload_handler',
```

### JWT_PAYLOAD_GET_USER_ID_HANDLER
If you store `user_id` differently than the default payload handler does, implement this function to fetch `user_id` from the payload. **Note:** Will be deprecated in favor of `JWT_PAYLOAD_GET_USERNAME_HANDLER`.

Expand Down