Half Your Users Can't Log In: Debugging Auth in a Vibe-Coded App
When login works for you but fails for a share of users, the cause is almost never "the password check". It is usually one of six things: session cookies blocked by the browser, token refresh racing across tabs, users stuck on an old session format after a migration, email address case mismatches, an OAuth redirect URL that differs between environments, or rate limits on the auth provider. Error monitoring tells you which one in an afternoon. Guessing takes months.
On this page
This year a founder brought us an app where about half of the users had not been able to log in for months. Sentry held around 200,000 error events. New complaints kept arriving from users, and there was a real risk that customer data could leak.
When the developers cannot see the failure themselves, remember that "works on my machine" in auth almost always means the difference sits in the user's browser, account history or network, not in the code path you test.
Step 1: group the errors before reading them
200,000 events sounds like 200,000 problems. Grouped by message and stack trace, they usually collapse into a handful of root causes. Sort by number of affected users, not by number of events. One user in a refresh loop can produce thousands of events on their own.
If you have no error monitoring at all, set it up before anything else. Logging in is the one flow you cannot debug from complaints. Here is our 30-minute Sentry setup for Next.js.
Step 2: check the six usual causes
1. Cookies the browser refuses to store
Safari and Firefox block third-party cookies by default. If your auth API lives on a different domain from your app (for example api.yourapp.io called from yourapp.com, or a hosted auth provider on its own domain), the session cookie may never be saved. The user signs in, gets redirected, and lands logged out.
Signal: failures cluster in Safari and iOS. Fix: put auth on the same site, or use a custom domain for the auth provider.
2. Token refresh racing across tabs
The user has two tabs open. Both notice the access token expired and both call refresh at the same moment. The provider rotates the refresh token on the first call, the second call presents the old one, and the provider treats that as token theft and signs the user out everywhere.
Signal: "invalid refresh token" or "refresh token already used" errors, users logged out mid-session. Fix: one refresh at a time (a lock in local storage or a broadcast channel), or rely on the SDK's built-in handling and remove your custom refresh code.
3. Old sessions after a migration
The app changed auth library, session format or JWT secret. New users are fine. Users with a session from before the change carry a cookie the new code cannot read, and the code throws instead of treating them as logged out.
Signal: failures only for accounts older than a certain date. Fix: on any session parse error, clear the cookie and send the user to login.
4. Email case and whitespace
Anna@Example.com signed up. anna@example.com tries to log in. Some providers normalise and some do not. Mobile keyboards add a trailing space or capitalise the first letter.
Signal: "user not found" for users who exist. Fix: lowercase and trim on signup and login, and run a one-off migration for existing rows.
5. Redirect URLs that differ by environment
OAuth providers only accept redirect URLs from an allowlist. AI-generated code often hardcodes localhost or reads the URL from an environment variable that is set in one deploy target and missing in another. www vs no-www counts as a different URL.
Signal: Google or GitHub login fails while email login works. Fix: one canonical domain, redirect the other, and list exact URLs per environment.
6. Rate limits on the auth provider
Free tiers of hosted auth limit sign-ins and emails per hour. A marketing push or a bot can use them up, and then legitimate users get errors.
Signal: failures in bursts at specific times. Fix: check the provider dashboard and add your own rate limiting in front.
Step 3: fix the cause, then prove it
For each fix, watch the error group in your monitoring tool. The count for that group should fall to near zero within a day or two of the deploy. If it does not, the fix addressed a symptom.
Should you rewrite auth?
Rarely. Replacing the auth system on a live app forces every user to reset their password or re-link their account, and it creates its own wave of support tickets. Fix the specific failures first. Consider a replacement only if the existing library is unmaintained or the data model fights you on every change.
If your users cannot log in and you cannot reproduce it, our app rescue and security audit starts exactly here: group the errors, find the causes, fix them in place.
