Skip to content

Commit

Permalink
Fix PyJWT (import jwt) code to work with latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
codyfletcher committed Jul 5, 2023
1 parent 579550a commit 6f6afb5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/source/samples/todo-app/code/chalicelib/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_jwt_token(username, password, record, secret):
record['hash'],
password.encode('utf-8'),
record['salt'].value,
record['rounds']
int(record['rounds'])
)
expected = record['hashed'].value
if hmac.compare_digest(actual, expected):
Expand All @@ -25,7 +25,7 @@ def get_jwt_token(username, password, record, secret):
'jti': unique_id,
# NOTE: We can also add 'exp' if we want tokens to expire.
}
return jwt.encode(payload, secret, algorithm='HS256').decode('utf-8')
return jwt.encode(payload, secret, algorithm='HS256')
raise UnauthorizedError('Invalid password')


Expand Down

0 comments on commit 6f6afb5

Please sign in to comment.