Skip to content

Commit 1a4870e

Browse files
Andreas MollAndreas Moll
authored andcommitted
Remove redundant jwt information on the context
1 parent 9aa6bd3 commit 1a4870e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

flask_jwt_extended/utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def get_jwt_identity():
3030
Returns the identity of the JWT in this context. If no JWT is present,
3131
None is returned.
3232
"""
33-
return getattr(ctx_stack.top, 'jwt_identity', None)
33+
return get_raw_jwt().get('identity', None)
3434

3535

3636
def get_jwt_claims():
3737
"""
3838
Returns the dictionary of custom use claims in this JWT. If no custom user
3939
claims are present, an empty dict is returned
4040
"""
41-
return getattr(ctx_stack.top, 'jwt_user_claims', {})
41+
return get_raw_jwt().get('user_claims', {})
4242

4343

4444
def get_raw_jwt():
@@ -241,8 +241,6 @@ def wrapper(*args, **kwargs):
241241

242242
# Save the jwt in the context so that it can be accessed later by
243243
# the various endpoints that is using this decorator
244-
ctx_stack.top.jwt_identity = jwt_data['identity']
245-
ctx_stack.top.jwt_user_claims = jwt_data['user_claims']
246244
ctx_stack.top.jwt = jwt_data
247245
return fn(*args, **kwargs)
248246
return wrapper
@@ -277,8 +275,6 @@ def wrapper(*args, **kwargs):
277275

278276
# Save the jwt in the context so that it can be accessed later by
279277
# the various endpoints that is using this decorator
280-
ctx_stack.top.jwt_identity = jwt_data['identity']
281-
ctx_stack.top.jwt_user_claims = jwt_data['user_claims']
282278
ctx_stack.top.jwt = jwt_data
283279
return fn(*args, **kwargs)
284280
return wrapper
@@ -306,7 +302,6 @@ def wrapper(*args, **kwargs):
306302

307303
# Save the jwt in the context so that it can be accessed later by
308304
# the various endpoints that is using this decorator
309-
ctx_stack.top.jwt_identity = jwt_data['identity']
310305
ctx_stack.top.jwt = jwt_data
311306
return fn(*args, **kwargs)
312307
return wrapper

0 commit comments

Comments
 (0)