From deed1c531814172b769940914e3fc11918e2a845 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 6 Apr 2018 11:48:36 +0200 Subject: [PATCH] app/library/Auth.php: in loginOAuth() we pass a UserDataInterface now. --- app/library/Auth.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/library/Auth.php b/app/library/Auth.php index 0aa51b5..e6e2333 100644 --- a/app/library/Auth.php +++ b/app/library/Auth.php @@ -2,6 +2,7 @@ namespace Httpcb; +use Httpcb\OAuth\UserData\UserDataInterface; use Phalcon\Mvc\User\Component; use App\Model\Data\User; @@ -42,24 +43,19 @@ class Auth extends Component /** * Login using OAuth * - * @param $auth + * @param UserDataInterface $auth */ - public function loginOauth($auth) + public function loginOauth(UserDataInterface $auth) { - $email = ''; - if (isset($auth['info']['email'])) { - $email = $auth['info']['email']; - } - // Look for a user with this email. - $user = User::findFirstByEmail($email); + $user = User::findFirstByEmail($auth->getEmail()); if (!$user) { // Did not find any user. create him. - if (isset($auth['info']['nickname'])) { - $name = $auth['info']['nickname']; - } else if(isset($auth['info']['name'])) { - $name = $auth['info']['name']; + if (strlen($auth->getUsername()) > 0) { + $name = $auth->getUsername(); + } else if(strlen($auth->getName()) > 0) { + $name = $auth->getName(); } else { $name = ''; } @@ -74,7 +70,7 @@ class Auth extends Component $this->setIdentity($user->getId()); $this->_eventsManager->fire('auth:onLogin', $this, - "OAuth {$auth['provider']}"); + "OAuth {$auth->getProvider()}"); } /**