From 40eb0f78e991f5cd08d97397809fbf680e2d26f9 Mon Sep 17 00:00:00 2001 From: AbdealiJK Date: Wed, 7 Mar 2018 00:26:52 +0530 Subject: [PATCH 1/2] _default_jwt_payload_handler: Check for attribute 'id' If the attribute 'id' does not exist, do not use it. Use the item 'id' instead. Fixes https://github.com/mattupstate/flask-jwt/issues/115 --- flask_jwt/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flask_jwt/__init__.py b/flask_jwt/__init__.py index f864b78..ef7f3f1 100644 --- a/flask_jwt/__init__.py +++ b/flask_jwt/__init__.py @@ -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__) @@ -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'] return {'exp': exp, 'iat': iat, 'nbf': nbf, 'identity': identity} From 90be0d0006fbd54db886329b6e550c01839c48b3 Mon Sep 17 00:00:00 2001 From: AbdealiJK Date: Wed, 7 Mar 2018 00:37:24 +0530 Subject: [PATCH 2/2] Change version everywhere --- CHANGES | 7 +++++++ docs/conf.py | 2 +- setup.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 5e6279f..814bab1 100644 --- a/CHANGES +++ b/CHANGES @@ -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 ------------- diff --git a/docs/conf.py b/docs/conf.py index 673f940..9cca7cf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 diff --git a/setup.py b/setup.py index 31e658d..1020cbc 100644 --- a/setup.py +++ b/setup.py @@ -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',