feat: resend email

# Conflicts:
#	app/Http/Controllers/AuthController.php
#	lang/en/api.php
#	lang/fr/api.php
#	tests/Feature/EmailVerificationTest.php
This commit is contained in:
2026-05-20 21:03:35 +02:00
parent bcc067ec67
commit 54503caf45
6 changed files with 60 additions and 10 deletions
+5 -3
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\EmailVerificationNotificationRequest;
use App\Http\Requests\LoginRequest;
use App\Http\Requests\RegisterRequest;
use App\Http\Requests\UpdateUserRequest;
@@ -107,9 +108,10 @@ class AuthController extends Controller
]);
}
public function sendVerificationEmail(Request $request): JsonResponse
public function sendVerificationEmail(EmailVerificationNotificationRequest $request): JsonResponse
{
$user = $request->user();
$email = strtolower($request->validated('email'));
$user = User::where('email', $email)->first();
if ($user->hasVerifiedEmail()) {
return response()->json([
@@ -120,7 +122,7 @@ class AuthController extends Controller
$user->sendEmailVerificationNotification();
return response()->json([
'message' => __('api.auth.verification_sent'),
'message' => __('api.auth.verification_sent_if_unverified'),
]);
}
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class EmailVerificationNotificationRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'string', 'email'],
];
}
}