Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

undefined method isValid() en Auth.php

Estas en el tema de undefined method isValid() en Auth.php en el foro de Frameworks y PHP orientado a objetos en Foros del Web. Hola buenas , tengo el siguiente mensaje de error,...y no se encontrar a que se debe, seguro que es problema del adaptador, alguien podria ayudarme ...
  #1 (permalink)  
Antiguo 10/06/2010, 09:22
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 7 meses
Puntos: 0
undefined method isValid() en Auth.php

Hola buenas , tengo el siguiente mensaje de error,...y no se encontrar a que se debe, seguro que es problema del adaptador, alguien podria ayudarme

Tengo un archivo config.php
Código PHP:
return array_merge_recursive(array(
    
'includePaths' => array(
        
'library' => APPLICATION_PATH '/library'
    
),
    
'bootstrap' => array(
        
'path'  => APPLICATION_PATH '/Bootstrap.php',
        
'class' => 'Bootstrap'
    
),
    
'autoloaderNamespaces' => array(
        
'App_'
    
),
    
'resources'   => array(
        
'frontController' => array(
            
'moduleDirectory' => APPLICATION_PATH '/modules'
            
//'defaultModule' => 'Default'
        
),
        
'modules' => array(),
        
'router' => array(
            
'routes' => include dirname(__FILE__) . '/routes.config.php'
        
),
        
'view' => array(
            
'helperPath' => array(
               
'App_View_Helper_' => APPLICATION_PATH '/library/App/View/Helper'
            
)
        ),
         
'layout' => array(
            
'layout'     => 'layout',
            
'layoutPath' => APPLICATION_PATH '/layouts/scripts'
        
),
        
'db' => array(
            
'adapter' => 'pdo_mysql',
            
'isDefaultTableAdapter' => true,
            
'params'  => array(
                
'charset' => 'utf8'
            
)
        )
    )
), include 
dirname(__FILE__) . '/' APPLICATION_ENV '.config.php'); 
En el modules- default-usercontrollers en la funcion de login tengo lo siguiente.
Código PHP:
 public function loginAction()
    {

         if (
$this->getRequest()->isPost()) {
               
$result Default_Service_ServiceAbstract::getService('Default_Service_User')
                          ->
login($this->getRequest()->getPost());
               echo 
$result;
         }
       
    
    } 
en la carpeta de model-mappers-mapperabstract.php esta.

Código PHP:
abstract class Default_Model_Mapper_MapperAbstract
{

     protected static 
$_defaultAdapter;
     protected 
$_adapter;

     public function  
__construct(Zend_Db_Adapter_Abstract $adapter null) {

        if (
$adapter === null) {
            
$adapter self::getDefaultAdapter();
        }
         if (
$adapter === null) {
           
$mensaje =  'No adapter was defined';
        }

         
$this->_adapter $adapter;
          
$this->_init();
     }
     public function  
_init()
     {

     }

     public function 
getDefaultAdapter()
     {
         return 
self::$_defaultAdapter;

     }
    public static function 
setDefaultAdapter(Zend_Db_Adapter_Abstract $adapter)
    {
        
self::$_defaultAdapter $adapter;
    }

Y donde salta el error es en modules-default-services-user.php en la siguiente funcion de login. En la clase Zend_Auth , de la libreria de Zend.
Dice que Call to undefined method Zend_Db_Adapter_Pdo_Mysql::isValid(). library\Zend\Auth.php on line 127
Código PHP:

    
public function login(array $data)
    {
        
$form $this->getLoginForm();
        
$a =;
        if (!
$form->isValid($data)) {
            return 
false;
        }
      
        
$this->_mapper ->setIdentity($data['username'])
                      ->
setCredential($data['password']);
        
$usuario =  $this->_mapper->setIdentity($data['username']);
        
$password =$this->_mapper->setCredential($data['password']);


        [
COLOR="black"]$result Zend_Auth::getInstance()->authenticate($this->_mapper);[/COLOR]

       
        if (!
$result->isValid()) {
            switch (
$result->getCode()) {
                case 
Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                    
$form->getElement('username')->setErrors(array('Username does not exist'));
                    break;

                case 
Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                    
$form->getElement('password')->setErrors(array('Password is not valid'));
                    break;

                case 
Zend_Auth_Result::FAILURE_UNCATEGORIZED:
                    
$form->getElement('username')->setErrors(array('Username was not confirmed yet'));
                    break;
            }
            
            return 
false;
        }

        if (
$data['remember'] === '1') {
           
        }

        return 
true;
    } 
Cual podria ser el error...muchas gracias.
  #2 (permalink)  
Antiguo 10/06/2010, 09:33
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: undefined method isValid() en Auth.php

Muy raro ya que es dentro de la librería de Zend, haz tratado de actualizar a la última versión?
  #3 (permalink)  
Antiguo 10/06/2010, 10:02
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: undefined method isValid() en Auth.php

Tengo esta version ,
ZendFramework-1.10.2

Y debe de ser de la aplicacion porque tengo otro formulario de login en otra aplicacion sin modulos y con configuracion diferente...que no da problemas...

Ando aprendiendo en Zend y cada vez intento mejorar la implementacion de la aplicacion...
  #4 (permalink)  
Antiguo 10/06/2010, 10:30
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: undefined method isValid() en Auth.php

He hecho un var_dump($result); en el metodo .
public function authenticate(Zend_Auth_Adapter_Interface $adapter)

de la clase Zend_Auth
y sale .
Código:
object(Zend_Db_Adapter_Pdo_Mysql)[7]
  protected '_pdoType' => string 'mysql' (length=5)
  protected '_numericDataTypes' => 
    array
      0 => int 0
      1 => int 1
      2 => int 2
      'INT' => int 0
      'INTEGER' => int 0
      'MEDIUMINT' => int 0
      'SMALLINT' => int 0
      'TINYINT' => int 0
      'BIGINT' => int 1
      'SERIAL' => int 1
      'DEC' => int 2
      'DECIMAL' => int 2
      'DOUBLE' => int 2
      'DOUBLE PRECISION' => int 2
      'FIXED' => int 2
      'FLOAT' => int 2
  protected '_defaultStmtClass' => string 'Zend_Db_Statement_Pdo' (length=21)
  protected '_config' => 
    array
      'charset' => string 'utf8' (length=4)
      'host' => string 'localhost' (length=9)
      'username' => string 'root' (length=4)
      'password' => string 'root' (length=5)
      'dbname' => string 'bas' (length=6)
      'persistent' => boolean false
      'options' => 
        array
          'caseFolding' => int 0
          'autoQuoteIdentifiers' => boolean true
      'driver_options' => 
        array
          empty
  protected '_fetchMode' => int 2
  protected '_profiler' => 
    object(Zend_Db_Profiler)[8]
      protected '_queryProfiles' => 
        array
          empty
      protected '_enabled' => boolean false
      protected '_filterElapsedSecs' => null
      protected '_filterTypes' => null
  protected '_defaultProfilerClass' => string 'Zend_Db_Profiler' (length=16)
  protected '_connection' => null
  protected '_caseFolding' => int 0
  protected '_autoQuoteIdentifiers' => boolean true
  protected '_allowSerialization' => boolean true
  protected '_autoReconnectOnUnserialize' => boolean false
quizas pueda ayudar a ver donde esta el error.....
  #5 (permalink)  
Antiguo 10/06/2010, 11:11
 
Fecha de Ingreso: agosto-2009
Mensajes: 138
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: undefined method isValid() en Auth.php

Esta solucionado ya , se me tenia error en model-mappers-user. authenticate().

ahora lo raro es que al hacer login me da.$result->isValid() false .FAILURE_IDENTITY_NOT_FOUND:


pero al hacer un print_r($this->_mapper); me da

Default_Model_Mapper_User Object ( [_identity:protected] => admin [_credential:protected] => admin [_table:protected] => usuarios [_adapter:protected] => Zend_Db_Adapter_Pdo_Mysql Object ( [_pdoType:protected] => mysql [_numericDataTypes:protected] => Array ( [0] => 0 [1] => 1 [2] => 2 [INT] => 0 [INTEGER] => 0 [MEDIUMINT] => 0 [SMALLINT] => 0 [TINYINT] => 0 [BIGINT] => 1 [SERIAL] => 1 [DEC] => 2 [DECIMAL] => 2 [DOUBLE] => 2 [DOUBLE PRECISION] => 2 [FIXED] => 2 [FLOAT] => 2 ) [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo [_config:protected] => Array ( [charset] => utf8 [host] => localhost [username] => root [password] => root[dbname] => bas[persistent] => [options] => Array ( [caseFolding] => 0 [autoQuoteIdentifiers] => 1 ) [driver_options] => Array ( ) ) [_fetchMode:protected] => 2 [_profiler:protected] => Zend_Db_Profiler Object ( [_queryProfiles:protected] => Array ( ) [_enabled:protected] => [_filterElapsedSecs:protected] => [_filterTypes:protected] => ) [_defaultProfilerClass:protected] => Zend_Db_Profiler [_connection:protected] => [_caseFolding:protected] => 0 [_autoQuoteIdentifiers:protected] => 1 [_allowSerialization:protected] => 1 [_autoReconnectOnUnserialize:protected] => ) )


y es raro porque si tengo una tabla usuarios con username de campo admin y password admin y role admin...

Seguire probando gracias y si alguien ve algo raro es de gran ayuda el comentario gracias...

Etiquetas: method, undefined
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:34.