Skip to content

Commit

Permalink
Merge pull request #6 from aspgems/master
Browse files Browse the repository at this point in the history
Fixes bug setting expiration period for token.
  • Loading branch information
rscarrera27 authored Nov 28, 2018
2 parents d9b3976 + c66a97e commit 27897a6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions flask_graphql_auth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ def _create_basic_token_data(identity, token_type):
}

if token_type == "refresh":
token_data.update({
"exp": current_app.config['JWT_REFRESH_TOKEN_EXPIRES']
})
exp = current_app.config['JWT_REFRESH_TOKEN_EXPIRES']
if isinstance(exp, int):
exp = datetime.timedelta(days=exp)
else:
token_data.update({
"exp": current_app.config['JWT_ACCESS_TOKEN_EXPIRES']
})
exp = current_app.config['JWT_ACCESS_TOKEN_EXPIRES']
if isinstance(exp, int):
exp = datetime.timedelta(minutes=exp)

token_data.update({
"exp": now + exp
})

return token_data

Expand Down Expand Up @@ -113,4 +117,3 @@ def _create_refresh_token(self, identity, user_claims):
json_encoder=current_app.json_encoder).decode('utf-8')

return encoded_token

0 comments on commit 27897a6

Please sign in to comment.