Skip to content

Commit a1af26e

Browse files
committed
Fix this extension when using Flask 1.x.x
Still need to get a unit test in place so this doesn't happen again. Refs #437
1 parent 7dca395 commit a1af26e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

flask_jwt_extended/view_decorators.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ def wrapper(fn):
119119
@wraps(fn)
120120
def decorator(*args, **kwargs):
121121
verify_jwt_in_request(optional, fresh, refresh, locations)
122-
return current_app.ensure_sync(fn)(*args, **kwargs)
122+
123+
# Compatibility with flask < 2.0
124+
try:
125+
return current_app.ensure_sync(fn)(*args, **kwargs)
126+
except AttributeError as e:
127+
if str(e) != "'Flask' object has no attribute 'ensure_sync'":
128+
raise
129+
return fn(*args, **kwargs)
123130

124131
return decorator
125132

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ cryptography==3.4.7
33
Flask==2.0.1
44
Pallets-Sphinx-Themes==2.0.1
55
pre-commit==2.13.0
6+
PyJWT==2.1.0
67
Sphinx==4.0.2
78
tox==3.23.1

0 commit comments

Comments
 (0)