Skip to content

Say what happened when a sign-in fails - #605

Merged
ericzakariasson merged 1 commit into
mainfrom
sign-in-error-message
Dec 1, 2026
Merged

ericzakariasson merged 1 commit into
mainfrom
sign-in-error-message

Conversation

@ericzakariasson

Copy link
Copy Markdown
Member

Summary

When a sign-in failed, the site said nothing. The visitor ended on "page not found" (the callback sent them to /auth/auth-code-error, which does not exist), or on the home page with the sign-in service's error in the address and nothing on the page.

Now a failed sign-in says what happened and what to do:

  • /auth/callback sends a failure to the sign-in page with a short code of our own, and keeps the page the visitor was heading for. The sign-in page shows the matching message above its buttons.
  • Any other page that receives a failure straight from the sign-in service shows the message as a toast and takes the service's parameters out of the address. The service does that when it doesn't accept the address it was asked to return to.
  • A failure is logged with the service's error code, so the reason can be found later.
Code When Message
several_accounts The email addresses on the GitHub or Google account match more than one account here We couldn't tell which account is yours. The email addresses on that account match more than one account here. Sign in the way you did before.
cancelled The person pressed Cancel at GitHub or Google Sign-in was cancelled
expired The attempt took too long, was used twice, or was finished in another browser That sign-in attempt expired. It took too long or was opened in another browser. Please sign in again.
unverified_email The email address on the account isn't verified That email address isn't verified. Verify the email address on your GitHub or Google account, then sign in again.
failed Anything else Sign-in didn't work. Please try again, or use the other sign-in method.

The messages are ours. Text from the address is never shown, since anyone can write an address. A successful sign-in goes where it did before.

Things to know

  • several_accounts is recognised by the wording of the service's description, because the service reports it under its general "unexpected failure" code. If that wording changes, the visitor gets the general message instead.
  • This explains the failure. It doesn't fix the cause: someone whose GitHub email addresses match two accounts here still can't sign in with GitHub until those accounts are merged.
  • The codes for expired and unverified_email come from the auth library's list of error codes. I have only seen several_accounts happen for real.

Testing

  • bunx biome ci . and bun run typecheck in apps/cursor pass.
  • Run locally, with addresses written by hand in the shape the service sends:
    • /auth/callback with each kind of failure redirects to /login with the right code. That includes the exact failure a member reported, a missing code, and a code with no sign-in in progress.
    • next is kept when it is a path on the site and dropped when it points elsewhere.
    • In a browser, the sign-in page shows the message, with no toast on top of it, and the service's fragment is removed from the address.
    • On other pages, a failure in the query, in the fragment or in both shows one toast. The address is cleaned and other parameters (?q=) stay.
    • A page's own ?error= without the service's other parameters is left alone, and an unknown code on the sign-in page shows nothing.
    • Markup in the parameters is not rendered anywhere.
  • Preview build: /auth/callback redirects the same way there, and the messages are in the page's scripts.
  • Not tested: a real failed sign-in from GitHub or Google. I did not cancel a real sign-in or cause the linking error on purpose.

A failed sign-in ended on a "page not found" (the callback sent the
visitor to /auth/auth-code-error, which does not exist) or on the home
page with the sign-in service's error in the address and nothing on the
page.

- /auth/callback now sends a failure to /login with our own short code
  (?error=several_accounts, cancelled, expired, unverified_email or
  failed) and keeps the page the visitor was heading for. The sign-in
  page shows the matching message above its buttons.
- When the service sends a failure straight to a page (it does when it
  does not accept the address it was asked to return to), any page shows
  the message as a toast and takes the service's parameters out of the
  address.
- The messages are ours. Text from the address is never shown, since
  anyone can write an address.
- A failure is logged with the service's error code, so the reason can
  be found later.

A successful sign-in goes where it did before.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ericzakariasson
ericzakariasson merged commit 98d178f into main Dec 1, 2026
1 check passed
@ericzakariasson
ericzakariasson deleted the sign-in-error-message branch December 1, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant