getAdapter(), $this->_name, 'email', 'password'); // Set credentials $authAdapter->setIdentity($email); $authAdapter->setCredential(hash('sha256',$password)); // Authenticate $result = $auth->authenticate($authAdapter); // Check result if ($result->isValid()) { // Keep all but password and salt in session. $storage = $auth->getStorage(); $storage->write($authAdapter->getResultRowObject(null, array('password', 'salt'))); return true; } return false; } /** * Fetch user based on email * * @return User */ public function findByEmail($email) { // Atleast 6 character long if (is_string($email) && isset($email[5])) { return $this->fetchRow($this->getAdapter()->quoteInto('email = ?', $email)); } return null; } /** * Get random user * * @return User */ public function findRandom() { return $this->fetchAll(null, 'RAND()', 1)->current(); } }