如果第三方登录未返回email, 则随机生成

如果第三方登录未返回email, 则随机生成

如果第三方登录未返回email, 则随机生成
This commit is contained in:
Edward Yang 2023-01-07 21:40:36 +08:00
parent 4d2e11057f
commit 0b1bb96039
1 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@
namespace Plugin\Social\Repositories;
use Beike\Models\Customer;
use Illuminate\Support\Str;
use Laravel\Socialite\Two\User;
use Beike\Shop\Services\AccountService;
use Illuminate\Database\Eloquent\Model;
@ -57,11 +58,14 @@ class CustomerRepo
}
$email = $userData->getEmail();
if (empty($email)) {
$email = strtolower(Str::random(8)) . "@{$provider}.com";
}
$customer = Customer::query()->where('email', $email)->first();
if (empty($customer)) {
$customerData = [
'from' => $provider,
'email' => $userData->getEmail(),
'email' => $email,
'name' => $userData->getName(),
'avatar' => $userData->getAvatar(),
];