- Backend: add forgot-password and reset-password endpoints with token-based flow (1h expiry, secure random token, email via existing EmailPort) - Backend: add PasswordResetTokenOrmEntity + migration - Backend: add siret field to RegisterOrganizationDto and pass it to org creation - Backend: remove MinLength(12) from LoginDto.password (wrong for login use case) - Backend: add rememberMe to LoginDto (optional, informational) - Frontend: register page rewritten as 2-step flow (account info → org info) with SIRET field, Suspense wrapper, "Centre d'aide" link removed - Frontend: forgot-password page rewritten in French, matching login style - Frontend: reset-password page rewritten in French, matching login style, with Suspense - Frontend: remember me now works — localStorage when checked, sessionStorage otherwise - Frontend: login page removes "Centre d'aide" link, connects rememberMe to login - Frontend: auth-context and api/auth updated to pass rememberMe through full chain Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
191 lines
8.5 KiB
TypeScript
191 lines
8.5 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import Link from 'next/link';
|
|
import Image from 'next/image';
|
|
import { forgotPassword } from '@/lib/api/auth';
|
|
|
|
export default function ForgotPasswordPage() {
|
|
const [email, setEmail] = useState('');
|
|
const [success, setSuccess] = useState(false);
|
|
const [error, setError] = useState('');
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
setError('');
|
|
setLoading(true);
|
|
|
|
try {
|
|
await forgotPassword(email);
|
|
setSuccess(true);
|
|
} catch (err: any) {
|
|
setError(err.message || 'Une erreur est survenue. Veuillez réessayer.');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="min-h-screen flex">
|
|
{/* Left Side - Form */}
|
|
<div className="w-full lg:w-1/2 flex flex-col justify-center px-8 sm:px-12 lg:px-16 xl:px-24 bg-white">
|
|
<div className="max-w-md w-full mx-auto">
|
|
{/* Logo */}
|
|
<div className="mb-10">
|
|
<Link href="/">
|
|
<Image
|
|
src="/assets/logos/logo-black.svg"
|
|
alt="Xpeditis"
|
|
width={50}
|
|
height={60}
|
|
priority
|
|
className="h-auto"
|
|
/>
|
|
</Link>
|
|
</div>
|
|
|
|
{success ? (
|
|
<>
|
|
<div className="mb-8">
|
|
<div className="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-6">
|
|
<svg className="w-8 h-8 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
|
|
</svg>
|
|
</div>
|
|
<h1 className="text-h1 text-brand-navy mb-2">Email envoyé</h1>
|
|
<p className="text-body text-neutral-600">
|
|
Si un compte est associé à <strong>{email}</strong>, vous recevrez un email avec
|
|
les instructions pour réinitialiser votre mot de passe.
|
|
</p>
|
|
<p className="text-body-sm text-neutral-500 mt-3">
|
|
Pensez à vérifier vos spams si vous ne recevez rien d'ici quelques minutes.
|
|
</p>
|
|
</div>
|
|
<Link href="/login" className="btn-primary w-full text-center block text-lg">
|
|
Retour à la connexion
|
|
</Link>
|
|
</>
|
|
) : (
|
|
<>
|
|
{/* Header */}
|
|
<div className="mb-8">
|
|
<h1 className="text-h1 text-brand-navy mb-2">Mot de passe oublié ?</h1>
|
|
<p className="text-body text-neutral-600">
|
|
Entrez votre adresse email et nous vous enverrons un lien pour réinitialiser votre mot de passe.
|
|
</p>
|
|
</div>
|
|
|
|
{/* Error Message */}
|
|
{error && (
|
|
<div className="mb-6 p-4 bg-red-50 border border-red-200 rounded-lg flex items-start gap-3">
|
|
<svg className="w-5 h-5 text-red-600 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
<p className="text-body-sm text-red-800">{error}</p>
|
|
</div>
|
|
)}
|
|
|
|
{/* Form */}
|
|
<form onSubmit={handleSubmit} className="space-y-6">
|
|
<div>
|
|
<label htmlFor="email" className="label">
|
|
Adresse email
|
|
</label>
|
|
<input
|
|
id="email"
|
|
type="email"
|
|
required
|
|
value={email}
|
|
onChange={e => setEmail(e.target.value)}
|
|
className="input w-full"
|
|
placeholder="votre.email@entreprise.com"
|
|
autoComplete="email"
|
|
disabled={loading}
|
|
/>
|
|
</div>
|
|
|
|
<button
|
|
type="submit"
|
|
disabled={loading}
|
|
className="btn-primary w-full text-lg disabled:opacity-50 disabled:cursor-not-allowed"
|
|
>
|
|
{loading ? 'Envoi en cours...' : 'Envoyer le lien de réinitialisation'}
|
|
</button>
|
|
</form>
|
|
|
|
<div className="mt-8 text-center">
|
|
<Link href="/login" className="text-body-sm link flex items-center justify-center gap-2">
|
|
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
|
</svg>
|
|
Retour à la connexion
|
|
</Link>
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{/* Footer Links */}
|
|
<div className="mt-8 pt-8 border-t border-neutral-200">
|
|
<div className="flex flex-wrap justify-center gap-6 text-body-sm text-neutral-500">
|
|
<Link href="/contact" className="hover:text-accent transition-colors">
|
|
Contactez-nous
|
|
</Link>
|
|
<Link href="/privacy" className="hover:text-accent transition-colors">
|
|
Confidentialité
|
|
</Link>
|
|
<Link href="/terms" className="hover:text-accent transition-colors">
|
|
Conditions
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Right Side - Brand */}
|
|
<div className="hidden lg:block lg:w-1/2 relative bg-brand-navy">
|
|
<div className="absolute inset-0 bg-gradient-to-br from-brand-navy to-neutral-800 opacity-95"></div>
|
|
<div className="absolute inset-0 flex flex-col justify-center px-16 xl:px-24 text-white">
|
|
<div className="max-w-xl">
|
|
<h2 className="text-display-sm mb-6 text-white">Sécurité avant tout</h2>
|
|
<p className="text-body-lg text-neutral-200 mb-12">
|
|
La protection de votre compte est notre priorité. Réinitialisez votre mot de passe en toute sécurité.
|
|
</p>
|
|
<div className="space-y-6">
|
|
<div className="flex items-start">
|
|
<div className="flex-shrink-0 w-12 h-12 bg-brand-turquoise rounded-lg flex items-center justify-center">
|
|
<svg className="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
|
|
</svg>
|
|
</div>
|
|
<div className="ml-4">
|
|
<h3 className="text-h5 mb-1 text-white">Lien sécurisé</h3>
|
|
<p className="text-body-sm text-neutral-300">Le lien expire après 1 heure pour votre sécurité</p>
|
|
</div>
|
|
</div>
|
|
<div className="flex items-start">
|
|
<div className="flex-shrink-0 w-12 h-12 bg-brand-turquoise rounded-lg flex items-center justify-center">
|
|
<svg className="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
|
|
</svg>
|
|
</div>
|
|
<div className="ml-4">
|
|
<h3 className="text-h5 mb-1 text-white">Email de confirmation</h3>
|
|
<p className="text-body-sm text-neutral-300">Vérifiez votre boîte de réception et vos spams</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="absolute bottom-0 right-0 opacity-10">
|
|
<svg width="400" height="400" viewBox="0 0 400 400" fill="none">
|
|
<circle cx="200" cy="200" r="150" stroke="currentColor" strokeWidth="2" className="text-white" />
|
|
<circle cx="200" cy="200" r="100" stroke="currentColor" strokeWidth="2" className="text-white" />
|
|
<circle cx="200" cy="200" r="50" stroke="currentColor" strokeWidth="2" className="text-white" />
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|