Skip to content

Commit

Permalink
better error messages for invalid vs expired token
Browse files Browse the repository at this point in the history
  • Loading branch information
zachliu committed Sep 12, 2024
1 parent 6047a65 commit de18d61
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions redash/handlers/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ def render_token_login_page(template, org_slug, token, invite):
),
400,
)
except (SignatureExpired, BadSignature):
logger.exception("Failed to verify invite token: %s, org=%s", token, org_slug)
except SignatureExpired:
logger.exception("Token signature has expired. Token: %s, org=%s", token, org_slug)
return (
render_template(
"error.html",
error_message="Your invite link has expired. Please ask for a new one.",
),
400,
)
except BadSignature:
logger.exception("Bad signature for the invite token: %s, org=%s", token, org_slug)
return (
render_template(
"error.html",
error_message="Your invite link is invalid. Please double-check the token.",
),
400,
)

if invite and user.details.get("is_invitation_pending") is False:
return (
Expand Down

0 comments on commit de18d61

Please sign in to comment.