You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
656 B
25 lines
656 B
from datetime import datetime
|
|
from calendar import timegm
|
|
from rest_framework_jwt.settings import api_settings
|
|
|
|
|
|
def custom_jwt_payload_handler(user):
|
|
|
|
payload = {
|
|
'exp': datetime.utcnow() + api_settings.JWT_EXPIRATION_DELTA,
|
|
'out_key': str(user.out_key),
|
|
'email': user.email,
|
|
}
|
|
|
|
if api_settings.JWT_ALLOW_REFRESH:
|
|
payload['orig_iat'] = timegm(
|
|
datetime.utcnow().utctimetuple()
|
|
)
|
|
|
|
if api_settings.JWT_AUDIENCE is not None:
|
|
payload['aud'] = api_settings.JWT_AUDIENCE
|
|
|
|
if api_settings.JWT_ISSUER is not None:
|
|
payload['iss'] = api_settings.JWT_ISSUER
|
|
|
|
return payload
|
|
|