update
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace App\Services\Api\Client;
|
||||
|
||||
use App\Mail\Customer\Welcome as WelcomeMail;
|
||||
use App\Models\RefreshToken;
|
||||
use App\Repositories\Api\Client\ClientRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
@@ -71,6 +74,8 @@ class ClientAuthService
|
||||
$token = JWTAuth::fromUser($client);
|
||||
$refreshToken = $this->createRefreshToken($client->id);
|
||||
|
||||
$this->sendWelcomeEmail($client);
|
||||
|
||||
return [
|
||||
'client' => $client,
|
||||
'token' => $token,
|
||||
@@ -78,6 +83,24 @@ class ClientAuthService
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gửi email chào mừng cho khách hàng mới đăng ký.
|
||||
*/
|
||||
protected function sendWelcomeEmail($client): void
|
||||
{
|
||||
try {
|
||||
Mail::to($client->email)->send(new WelcomeMail([
|
||||
'fullname' => $client->fullname,
|
||||
'email' => $client->email,
|
||||
]));
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('Send welcome email failed: ' . $e->getMessage(), [
|
||||
'customer_id' => $client->id,
|
||||
'email' => $client->email,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tạo refresh token mới, lưu hash vào DB, trả về raw token.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user