File manager - Edit - /var/www/html/homologBancodetalentos/app/Http/Services/TalentBank/PasswordRecoveryService.php
Back
<?php namespace App\Http\Services\TalentBank; use App\Http\Services\AuthService; use App\Support\TalentBank\IntegrationLog; use Illuminate\Http\Client\RequestException; use Illuminate\Http\Client\Response; use Illuminate\Http\Request; /** * Recuperação de senha via API de identidade (AUTH_SERVICE_URL). * Não persiste tokens no BT: o código é validado e a senha alterada no serviço central. */ class PasswordRecoveryService { public function __construct( private AuthService $authService ) { } public function sendRecoveryEmail(string $documentDigits, string $email): Response { $sub = Request::create('/internal', 'POST', [ 'document' => $documentDigits, 'email' => mb_strtolower(trim($email)), ]); try { $response = $this->authService->sendEmail($sub); } catch (RequestException $e) { $response = $e->response; } $this->logSendResponse($response, $documentDigits, $email); return $response; } public function resetPassword(string $code, string $newPassword, string $confirmation): Response { $sub = Request::create('/internal', 'POST', [ 'code' => $code, 'new_password' => $newPassword, 'new_password_confirmation' => $confirmation, ]); try { $response = $this->authService->resetPassword($sub); } catch (RequestException $e) { $response = $e->response; } $this->logResetResponse($response, $code); return $response; } private function logSendResponse(Response $response, string $documentDigits, string $email): void { IntegrationLog::info('talent_bank.password_recovery', 'send', [ 'http_status' => $response->status(), 'document_masked' => $this->maskDocument($documentDigits), 'email_masked' => $this->maskEmail($email), ]); } private function logResetResponse(Response $response, string $code): void { IntegrationLog::info('talent_bank.password_recovery', 'reset', [ 'http_status' => $response->status(), 'code_length' => strlen($code), ]); } private function maskDocument(string $digits): string { $len = strlen($digits); if ($len <= 4) { return str_repeat('*', $len); } return substr($digits, 0, 3).str_repeat('*', max(0, $len - 5)).substr($digits, -2); } private function maskEmail(string $email): string { $parts = explode('@', $email, 2); if (count($parts) !== 2) { return '***'; } $local = $parts[0]; $domain = $parts[1]; $first = mb_substr($local, 0, 1); return $first.'***@'.$domain; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings