- Added localization support for API responses in English and Spanish. - Introduced a middleware to set the API locale based on the Accept-Language header. - Updated various exception messages and validation responses to use localized strings. - Created new language files for English and Spanish translations. - Refactored existing code to replace hardcoded messages with localized strings. - Added tests to verify localization functionality and response correctness.
33 lines
995 B
PHP
33 lines
995 B
PHP
<?php
|
|
|
|
namespace App\Domains\Auth\Controllers;
|
|
|
|
use App\Domains\Auth\Models\ResetPasswordAttempt;
|
|
use App\Domains\Auth\Requests\CreateResetPasswordAttemptRequest;
|
|
use App\Domains\Auth\Services\ResetPasswordAttemptService;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class CreateResetPasswordAttemptController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly ResetPasswordAttemptService $resetPasswordAttemptService,
|
|
) {}
|
|
|
|
public function __invoke(CreateResetPasswordAttemptRequest $request): JsonResponse
|
|
{
|
|
$data = $request->validated();
|
|
|
|
$this->resetPasswordAttemptService->createForEmail(
|
|
$data['email'],
|
|
$data['tenant_codigo'],
|
|
);
|
|
|
|
return response()->json([
|
|
'code' => 'auth.password_reset_requested',
|
|
'message' => __('api.auth.password_reset_requested'),
|
|
'status' => ResetPasswordAttempt::STATUS_PENDING,
|
|
], 202);
|
|
}
|
|
}
|