Archived
1
0
Fork 0

app/library/Auth.php: in loginAuth() lookup by OAuth provider id.

This commit is contained in:
Henrik Hautakoski 2018-06-07 23:41:44 +02:00
parent 643387b3f3
commit bbcf6d2644

View file

@ -45,32 +45,20 @@ class Auth extends Component
*
* @param UserDataInterface $auth
*/
public function loginOauth(UserDataInterface $auth)
public function loginOauth(UserDataInterface $data)
{
// Look for a user with this email.
$user = User::findFirstByEmail($auth->getEmail());
$user = User::findFirstByOAuthID($data);
if (!$user) {
// Did not find any user. create him.
if (strlen($auth->getUsername()) > 0) {
$name = $auth->getUsername();
} else if(strlen($auth->getName()) > 0) {
$name = $auth->getName();
} else {
$name = '';
}
$user = new User();
$user->setEmail($auth->getEmail())
->setUsername($name);
$user = User::createFromOAuthData($data);
$user->save();
}
$this->setIdentity($user->getId());
$this->_eventsManager->fire('auth:onLogin', $this,
"OAuth {$auth->getProvider()}");
"OAuth {$data->getProvider()}");
}
/**