feat: enhance authentication UX with password visibility toggle and better error messages

Added comprehensive improvements to the login and authentication flow:

**UI Improvements:**
- Add password visibility toggle (Eye/EyeOff icons) for password fields
- Improve error message consistency with Dutch translations
- Fix syntax error in login page try-catch block

**Error Handling:**
- Add user-friendly error messages for invalid credentials
- Add specific error codes: invalid_credentials, email_not_confirmed
- Improve error message for non-existent accounts during login
- Handle duplicate email detection during signup with auto-switch to login mode

**Middleware:**
- Add /reset-password and /update-password to public routes
- Fix redirect issue preventing access to password reset flow

**Password Reset Flow:**
- Verify password reset works for magic link users (can set initial password)
- Ensure existing password users can reset their password
- Both flows use the same update mechanism via Supabase

**Documentation:**
- Add comprehensive release notes in docs/RELEASE_AUTH_IMPROVEMENTS.md

All changes maintain backward compatibility with existing magic link users.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
colinislit
2025-11-19 11:24:28 +01:00
parent 2505b27437
commit 2fcf609e27
4 changed files with 160 additions and 25 deletions

View File

@@ -158,7 +158,29 @@ export async function loginWithPassword(email: string, password: string) {
password
})
if (error) throw error
if (error) {
// Provide user-friendly error messages
const errorMessage = error.message?.toLowerCase() || ''
// Invalid login credentials (account doesn't exist OR wrong password)
if (errorMessage.includes('invalid login credentials') ||
errorMessage.includes('invalid credentials') ||
error.status === 400) {
const friendlyError = new Error('Email of wachtwoord is onjuist. Controleer je gegevens en probeer opnieuw.')
;(friendlyError as any).code = 'invalid_credentials'
throw friendlyError
}
// Email not confirmed
if (errorMessage.includes('email not confirmed')) {
const friendlyError = new Error('Je email is nog niet geverifieerd. Check je inbox voor de verificatie link.')
;(friendlyError as any).code = 'email_not_confirmed'
throw friendlyError
}
// Generic error fallback
throw error
}
return {
success: true,