getPassword(); if (strlen($hash) > 1 && $this->security->checkHash($password, $hash)) { $this->setIdentity($user->getId()); $this->eventsManager->fire('auth:onLogin', $this, 'password'); return true; } } return false; } /** * Login using OAuth * * @param UserDataInterface $data * @return bool|\Phalcon\Mvc\Model\MessageInterface[] */ public function loginOauth(UserDataInterface $data) { $user = User::findFirstByOAuthID($data); if (!$user) { // Did not find any user. create him. $user = User::createFromOAuthData($data); if ($user->save() === false) { return $user->getMessages(); } } $this->setIdentity($user->getId()); $this->eventsManager->fire('auth:onLogin', $this, "OAuth {$data->getProvider()}"); return true; } /** * @param $identity * @return Auth */ public function setIdentity($identity) { $this->session->set($this->_session_key, $identity); return $this; } /** * return \Model\Data\User */ public function getIdentity() { $id = $this->session->get($this->_session_key); if ($id !== null) { return User::findFirst($id); } return null; } /** * return \Model\Data\User */ public function getUser() { if ($this->hasIdentity()) { $id = $this->session->get($this->_session_key); return User::findFirst($id); } return null; } public function hasIdentity() { return $this->getIdentity() !== NULL; } /** * Clears the identity information. * * @return Auth */ public function clearIdentity() { $this->session->remove($this->_session_key); return $this; } }