Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

_default_jwt_payload_handler: Check for attribute 'id' #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Flask-JWT Changelog

Here you can see the full list of changes between each Flask-JWT release.

Version 0.3.3
-------------

Released March 7th 2018 (by AbdealiJK)

- Fixed an error when finding attribute 'id'

Version 0.3.2
-------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# built documents.
#
# The short X.Y version.
version = '0.3.2'
version = '0.3.3'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
7 changes: 5 additions & 2 deletions flask_jwt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from flask import current_app, request, jsonify, _request_ctx_stack
from werkzeug.local import LocalProxy

__version__ = '0.3.2'
__version__ = '0.3.3'

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -50,7 +50,10 @@ def _default_jwt_payload_handler(identity):
iat = datetime.utcnow()
exp = iat + current_app.config.get('JWT_EXPIRATION_DELTA')
nbf = iat + current_app.config.get('JWT_NOT_BEFORE_DELTA')
identity = getattr(identity, 'id') or identity['id']
if hasattr(identity, 'id'):
identity = getattr(identity, 'id')
else:
identity = identity['id']
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not identity = getattr(identity, 'id', None) or identity['id'] as suggested in #115 (comment) ?

return {'exp': exp, 'iat': iat, 'nbf': nbf, 'identity': identity}


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run_tests(self):

setup(
name='Flask-JWT',
version='0.3.2',
version='0.3.3',
url='https://github.com/mattupstate/flask-jwt',
license='MIT',
author='Matt Wright',
Expand Down