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

could i add other information to payload? #367

Closed
vparenti opened this issue Sep 13, 2017 · 4 comments
Closed

could i add other information to payload? #367

vparenti opened this issue Sep 13, 2017 · 4 comments
Labels

Comments

@vparenti
Copy link

I would like add more information in payload json, for example 'role' and 'company'.
Is there a way?
Thanks,
V

@blueyed blueyed added the docs label Sep 21, 2017
@MauScheff
Copy link

+1

@Alex3917
Copy link
Contributor

Alex3917 commented Oct 6, 2017

You just make a custom payload handler, e.g.:

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

Then in your settings you just need:

JWT_AUTH['JWT_PAYLOAD_HANDLER'] = 'path.to.your.jwt_custom_payload_handler'

@blueyed
Copy link
Contributor

blueyed commented Oct 7, 2017

Could we add this to the docs then?
@vparenti / @mauzepeda a PR would be welcome.

@blueyed
Copy link
Contributor

blueyed commented Oct 9, 2017

Closing in favor of #389 already.
Thanks, @mauzepeda!

@blueyed blueyed closed this as completed Oct 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants