re #309 remove the creation of a user on social auth and force creation of account through RegistrationController
This commit is contained in:
@ -104,40 +104,13 @@ class SocialNetworkAuthenticateService implements ServiceInterface
|
||||
if (($user = $this->getUser($account)) instanceof User) {
|
||||
$account->user_id = $user->id;
|
||||
$account->save(false);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $account;
|
||||
}
|
||||
|
||||
protected function getUser(SocialNetworkAccount $account)
|
||||
{
|
||||
$user = $this->userQuery->whereEmail($account->email)->one();
|
||||
if (null !== $user) {
|
||||
return $user;
|
||||
}
|
||||
/** @var User $user */
|
||||
$user = $this->controller->make(
|
||||
User::class,
|
||||
[],
|
||||
[
|
||||
'scenario' => 'connect',
|
||||
'username' => $account->username,
|
||||
'email' => $account->email,
|
||||
]
|
||||
);
|
||||
|
||||
if (!$user->validate(['email'])) {
|
||||
$user->email = null;
|
||||
}
|
||||
|
||||
if (!$user->validate(['username'])) {
|
||||
$user->username = null;
|
||||
}
|
||||
|
||||
$mailService = MailFactory::makeWelcomeMailerService($user);
|
||||
|
||||
return $this->controller->make(UserCreateService::class, [$user, $mailService])->run() ? $user : false;
|
||||
return $this->userQuery->whereEmail($account->email)->one();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user