Description
Implement password reset functionality and Google OAuth authentication using BetterAuth.
Tasks
Password Reset
Google OAuth
Error Handling & UX
Technical Details
Password Reset Flow
- User enters email on forgot-password page
- System generates secure token (1 hour expiration)
- Email sent via Resend with reset link
- User clicks link → reset-password page with token
- User enters new password (with confirmation)
- Token validated (exists, not expired, single-use)
- Password updated, token invalidated
- User redirected to sign-in with success message
Google OAuth Flow
// In src/lib/auth.ts
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
redirectURI: `${process.env.BETTER_AUTH_URL}/api/auth/callback/google`
}
}
Email Template (Resend)
- Subject: "Reset your Advienté password"
- Body: Branded HTML with reset link
- Link format:
${baseURL}/reset-password?token=${token}
- Token expiration: 1 hour
- Single-use token enforcement
Security Considerations
- ✅ Secure token generation (cryptographically random)
- ✅ Token expiration (1 hour maximum)
- ✅ Single-use tokens (mark as used after reset)
- ✅ Rate limiting on forgot-password requests (prevent spam)
- ✅ HTTPS only cookies for OAuth
- ✅ CSRF protection for OAuth callback
- ✅ Validate redirect URLs (prevent open redirect)
- ✅ Password strength validation (HTML5 + server-side)
- ✅ Account linking validation (same email check)
Definition of Done
Dependencies
Files to Create/Modify
src/app/forgot-password/page.tsx (new)
src/app/reset-password/page.tsx (update existing placeholder)
src/app/sign-in/page.tsx (add forgot password link)
src/app/sign-up/page.tsx (add Google sign-up button)
src/lib/auth.ts (uncomment Google provider config)
src/lib/email.ts (new - Resend integration)
.env (add Resend + Google keys)
Phase: 1.2 Security & Auth Core
Milestone: MVP
Priority: High
Description
Implement password reset functionality and Google OAuth authentication using BetterAuth.
Tasks
Password Reset
Google OAuth
src/lib/auth.tsError Handling & UX
Technical Details
Password Reset Flow
Google OAuth Flow
Email Template (Resend)
${baseURL}/reset-password?token=${token}Security Considerations
Definition of Done
Dependencies
Files to Create/Modify
src/app/forgot-password/page.tsx(new)src/app/reset-password/page.tsx(update existing placeholder)src/app/sign-in/page.tsx(add forgot password link)src/app/sign-up/page.tsx(add Google sign-up button)src/lib/auth.ts(uncomment Google provider config)src/lib/email.ts(new - Resend integration).env(add Resend + Google keys)Phase: 1.2 Security & Auth Core
Milestone: MVP
Priority: High