Skip to content

Commit

Permalink
Added JWT_PAYLOAD_HANDLER usage example to the docs. jpadilla#367 (co…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mau committed Oct 9, 2017
1 parent 0a0bd40 commit 1300b5d
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 1300b5d

Please sign in to comment.