Skip to content

Commit ce8bfb7

Browse files
committed
feat: Add explicit user existence check in forgot password flow and introduce dedicated email template.
1 parent 5f5093c commit ce8bfb7

2 files changed

Lines changed: 74 additions & 1 deletion

File tree

app/Http/Controllers/Auth/ForgotPasswordController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Http\Controllers\Controller;
66
use App\Mail\ForgotPasswordMail;
7+
use App\Models\User;
78
use Illuminate\Http\Request;
89
use Illuminate\Support\Facades\DB;
910
use Illuminate\Support\Facades\Mail;
@@ -12,7 +13,11 @@ class ForgotPasswordController extends Controller
1213
{
1314
public function sendForgotPasswordOtp(Request $request)
1415
{
15-
$request->validate(['email' => 'required|email|exists:users,email']);
16+
$user = User::where('email', $request->email)->first();
17+
18+
if (!$user) {
19+
return response()->json(['message' => 'Email non trouvé'], 422);
20+
}
1621

1722
$otp = rand(100000, 999999);
1823

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Récupération de mot de passe - Akevas</title>
8+
</head>
9+
10+
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f4f4;">
11+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
12+
<tr>
13+
<td style="padding: 20px 0 30px 0;">
14+
<table align="center" border="0" cellpadding="0" cellspacing="0" width="400" style="border-collapse: collapse; border: 1px solid #cccccc; background-color: #ffffff; border-radius: 15px; overflow: hidden;">
15+
<tr>
16+
<td align="center" style="padding: 40px 0 30px 0; background-color: #ffffff;">
17+
<h1 style="color: #ed7e0f; margin: 0; font-size: 28px; font-weight: bold;">AKEVAS</h1>
18+
</td>
19+
</tr>
20+
<tr>
21+
<td style="padding: 40px 30px 40px 30px;">
22+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
23+
<tr>
24+
<td style="color: #153643; font-size: 18px; font-weight: bold; padding-bottom: 20px;">
25+
Réinitialisation de votre mot de passe
26+
</td>
27+
</tr>
28+
<tr>
29+
<td style="color: #444444; font-size: 16px; line-height: 24px; padding-bottom: 30px;">
30+
Bonjour,<br><br>
31+
Vous avez demandé la réinitialisation de votre mot de passe sur Akevas. Utilisez le code de vérification ci-dessous pour continuer :
32+
</td>
33+
</tr>
34+
<tr>
35+
<td align="center" style="padding: 20px 0;">
36+
<div style="background-color: #f8f9fa; border: 2px dashed #ed7e0f; border-radius: 10px; padding: 20px; display: inline-block;">
37+
<span style="font-size: 32px; font-weight: bold; letter-spacing: 5px; color: #333333;">
38+
{{ $otp }}
39+
</span>
40+
</div>
41+
</td>
42+
</tr>
43+
<tr>
44+
<td style="color: #666666; font-size: 14px; line-height: 20px; padding-top: 30px; text-align: center;">
45+
Ce code est valide pendant <strong>15 minutes</strong>. Si vous n'êtes pas à l'origine de cette demande, vous pouvez ignorer cet e-mail en toute sécurité.
46+
</td>
47+
</tr>
48+
</table>
49+
</td>
50+
</tr>
51+
<tr>
52+
<td style="padding: 30px; background-color: #ed7e0f;">
53+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
54+
<tr>
55+
<td style="color: #ffffff; font-size: 12px; text-align: center;">
56+
&copy; {{ date('Y') }} Akevas. Tous droits réservés.
57+
</td>
58+
</tr>
59+
</table>
60+
</td>
61+
</tr>
62+
</table>
63+
</td>
64+
</tr>
65+
</table>
66+
</body>
67+
68+
</html>

0 commit comments

Comments
 (0)