re #309 remove the creation of a user on social auth and force creation of account through RegistrationController

This commit is contained in:
tonydspaniard
2019-06-17 17:35:22 +02:00
parent 222483253c
commit dd407f50b4
3 changed files with 8 additions and 36 deletions

View File

@ -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();
}
}