Beispiel #1
0
 /** 
  * To validate the user name 
  * and password is valids or not
  * @param <string> $username
  * @param <string> $password
  */
 public function userAuthenticate($username, $password)
 {
     $db_adapter = Application_Model_DbTable_DbUsers::getDefaultAdapter();
     $auth_adapter = new Zend_Auth_Adapter_DbTable($db_adapter);
     $auth_adapter->setTableName($this->_name)->setIdentityColumn('user_name')->setCredentialColumn('password')->setCredentialTreatment('MD5(?) AND active=1');
     // optional if password has been hashed
     $auth_adapter->setIdentity($username);
     // set value of username field
     $auth_adapter->setCredential($password);
     // set value of password field
     //instantiate Zend_Auth class
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($auth_adapter);
     if ($result->isValid()) {
         return true;
     } else {
         return false;
     }
 }