/** * Performs an authentication attempt * * @return \Zend\Authentication\Result * @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface * If authentication cannot be performed */ public function authenticate() { // look up $user from the database $user = $this->model->findOne(array('email' => $this->username)); // if a user was found, return the appropriate Result if ($user and password_verify($this->password, $user->password)) { return new Result(Result::SUCCESS, $this->username, array()); } else { return new Result(Result::FAILURE_IDENTITY_NOT_FOUND, null, array()); } }
/** * This is the identity (e.g. username) stored for this user * @return string */ public function getCurrentUser() { if (!$this->currentUser) { // get the identity (email) from the auth service // return null if not set $identity = $this->getIdentity(); if (!$identity) { return null; } // lookup the user by identity $this->currentUser = $this->userModel->findOne(array('email' => $identity)); } return $this->currentUser; }