Update findEmail() method for ProviderUser
This commit is contained in:
parent
4810de11d8
commit
934f7a1da0
2 changed files with 8 additions and 9 deletions
|
@ -88,7 +88,7 @@ class RegLog extends Page
|
|||
if (empty($uid)) {
|
||||
// на форуме есть пользователь с таким email
|
||||
if (
|
||||
$this->c->providerUser->findEmail($provider) > 0
|
||||
$this->c->providerUser->findByEmail($provider->userEmail) > 0
|
||||
|| $this->c->users->loadByEmail($provider->userEmail) instanceof User
|
||||
) {
|
||||
$auth = $this->c->Auth;
|
||||
|
@ -182,7 +182,7 @@ class RegLog extends Page
|
|||
return $redirect->message('Already linked to another', FORK_MESS_WARN, 5);
|
||||
}
|
||||
|
||||
$uid = $this->c->providerUser->findEmail($provider);
|
||||
$uid = $this->c->providerUser->findByEmail($provider->userEmail);
|
||||
|
||||
// email принадлежит другому пользователю
|
||||
if (
|
||||
|
|
|
@ -53,17 +53,16 @@ class ProviderUser extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Возращает id локального пользователя по данным провайдера или 0
|
||||
* Поиск идет по email
|
||||
* Возращает id локального пользователя по email или 0
|
||||
*/
|
||||
public function findEmail(Driver $provider): int
|
||||
public function findByEmail(string $email): int
|
||||
{
|
||||
if ('' == $provider->userEmail) {
|
||||
throw new RuntimeException('The user email is empty');
|
||||
if ('' == $email) {
|
||||
throw new RuntimeException('The email is empty');
|
||||
}
|
||||
|
||||
$vars = [
|
||||
':email' => $this->c->NormEmail->normalize($provider->userEmail),
|
||||
':email' => $this->c->NormEmail->normalize($email),
|
||||
];
|
||||
$query = 'SELECT pu.uid
|
||||
FROM ::providers_users AS pu
|
||||
|
@ -74,7 +73,7 @@ class ProviderUser extends Model
|
|||
$count = \count($result);
|
||||
|
||||
if ($count > 1) {
|
||||
throw new RuntimeException("Many entries for '{$provider->userEmail}'");
|
||||
throw new RuntimeException("Many entries for '{$email}'");
|
||||
}
|
||||
|
||||
return $count ? \array_pop($result) : 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue