Skip to content

Commit

Permalink
Log warnings in jwt error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Dec 14, 2023
1 parent d6b868f commit a4d36bb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qwc_services_core/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,23 @@ def restplus_error_handler(error):
@jwt.expired_token_loader
def handle_expired_token(jwtheader, jwtdata):
# Unset cookies and redirect to requested page on expired token
app.logger.warn("Expired token: %s" % str(err))
resp = redirect(request.url)
unset_jwt_cookies(resp)
return resp

@jwt.invalid_token_loader
def handle_invalid_token(err):
# Unset cookies and redirect to requested page on token error
app.logger.warn("Invalid token: %s" % str(err))
resp = redirect(request.url)
unset_jwt_cookies(resp)
return resp

@jwt.unauthorized_loader
def unauthorized(err):
# Redirect to requested page on authorized error (i.e. CSRF token error)
app.logger.warn("Unauthorized: %s" % str(err))
return redirect(request.url)

return jwt

0 comments on commit a4d36bb

Please sign in to comment.