Skip to content

Commit

Permalink
Merge pull request #54 from avantifellows/bug/update-refr-tok
Browse files Browse the repository at this point in the history
Update refresh token code to add claims
  • Loading branch information
suryabulusu authored Aug 27, 2024
2 parents c3f9319 + a15936b commit b229b5e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/router/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def create_access_token(auth_user: AuthUser, Authorize: AuthJWT = Depends()):
def refresh_token(Authorize: AuthJWT = Depends()):
Authorize.jwt_refresh_token_required()
current_user = Authorize.get_jwt_subject()
new_access_token = Authorize.create_access_token(subject=current_user)
old_data = Authorize.get_raw_jwt()
if "group" in old_data:
custom_claims = {"group": old_data["group"]}
else:
custom_claims = {}
new_access_token = Authorize.create_access_token(
subject=current_user, user_claims=custom_claims
)
return {"access_token": new_access_token}


Expand Down

0 comments on commit b229b5e

Please sign in to comment.