Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 3x 3x 12x 11x 10x 10x 9x 7x 1x 6x 6x 5x 5x 4x 1x 3x 1x 2x | /**
* Error codes used by the auth callback (/auth/callback) when redirecting to /login.
* These are URL query parameter values — keep in sync with the callback server handler
* and the login page's callbackErrors display mapping.
*/
export const CALLBACK_ERROR = {
LINK_EXPIRED: 'link_expired',
MISSING_CODE: 'missing_code',
} as const;
/**
* Maps callback error codes to user-friendly messages for display on the login page.
*/
export const callbackErrorMessages: Record<string, string> = {
[CALLBACK_ERROR.LINK_EXPIRED]: 'Your link has expired or was already used. Please request a new one.',
[CALLBACK_ERROR.MISSING_CODE]: 'This link has expired or is invalid. Please request a new one.',
};
/**
* Maps common Supabase Auth error messages to user-friendly text.
*/
export function friendlyError(msg: string): string {
if (msg === 'Invalid login credentials') return 'Email or password is incorrect';
if (msg === 'User already registered') return 'An account with this email already exists';
if (msg === 'Email not confirmed')
return 'Please check your email and confirm your account before signing in';
if (/rate limit/i.test(msg)) return 'Too many attempts, please try again later';
if (/password.*at least/i.test(msg) || /password.*too short/i.test(msg))
return 'Password must be at least 6 characters';
if (/password.*different from.*old/i.test(msg))
return 'New password must be different from your current password';
if (/auth session missing/i.test(msg))
return 'Your session has expired. Please request a new password reset link.';
if (/token.*expired/i.test(msg) || /token.*invalid/i.test(msg) || /otp.*expired/i.test(msg))
return 'This link has expired. Please request a new one.';
if (/signups.*disabled/i.test(msg) || /signups.*not allowed/i.test(msg))
return 'Sign-ups are currently unavailable. Please try again later.';
// Default: never pass raw Supabase error messages to the UI — they may contain
// internal identifiers or information that aids enumeration attacks.
return 'Something went wrong. Please try again.';
}
|