Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/11/2008, 08:33
Droller
 
Fecha de Ingreso: diciembre-2006
Mensajes: 15
Antigüedad: 17 años, 4 meses
Puntos: 0
Problema con sistema de login en ZF

Buenas, como andan?
Llego a ustedes para ver si me pueden ayudar con un problemita que estoy teniendo a la hora de validar un login zon ZF.

Paso a detallar el problema:

1. Mi controlador tiene un Action llamado loginAction(), aqui es a donde se dirige el formulario de login una vez completado:

Código PHP:
[FONT="Courier New"]    public function loginAction()
    {
        if(
$this->getRequest()->isPost()){
            
$usuario $this->_request->getPost('usuario');
            
$password $this->_request->getPost('password');
            
            
$mensajes = array(
                
UsuarioModel::NOT_IDENTITY => 'El nombre de usuario y password no coinciden',
                
UsuarioModel::INVALID_CREDENTIAL => 'hola',
                
UsuarioModel::INVALID_LOGIN => 'No puede dejar campos en blanco'
            
);
            
            try {
                
$usuario = new UsuarioModel();
                
$usuario->setMensajes($mensajes);
                
$usuario->login($usuario$password);
                
$this->_redirect();
            }catch (
Exception $e){
                
$mensajeLogin $e->getMessage();
            }
            
            
$this->view->mensajeLogin $mensajeLogin;
        }
    }[/
FONT
Como pueden ver, uso un Model llamado UsuarioModel, que se encarga de gestionar todo lo referido a la comprobacion de los datos frente a la base de datos con el metodo login().
Aqui esta UsuarioModel:
Código PHP:
[FONT="Courier New"]
    public function 
login($usuario$password)
    {
        if(!empty(
$usuario) && !empty($password)){

            
$autAdapter = new Zend_Auth_Adapter_DbTable(self::getDefaultAdapter());
            
$autAdapter->setTableName('usuarios');
            
$autAdapter->setIdentityColumn('usuario');
            
$autAdapter->setCredentialColumn('password');
            
$autAdapter->setIdentity($usuario);
            
$autAdapter->setCredential($password);
            
            
$auth Zend_Auth::getInstance();
        
            
$resultado $auth->authenticate($autAdapter);
            
            switch(
$resultado->getCode()){
                case 
Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                    throw new 
Exception($this->_mensajes[self::NOT_IDENTITY]);
                    break;
                case 
Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                    throw new 
Exception($this->_mensajes[self::INVALID_CREDENTIAL]);
                    break;
                case 
Zend_Auth_Result::SUCCESS:
                    if(
$resultado->isValid()){
                        
$data $autAdapter->getResultRowObject();
                        
$auth->getStorage()->write($data);
                    }
                    else{
                        throw new 
Exception($this->_mensajes[self::INVALID_USER]);
                    }
                    break;
                default:
                    throw new 
Exception($this->_mensajes[self::INVALID_LOGIN]);
                    break;
            }
        }else{
            throw new 
Exception($this->_mensajes[self::INVALID_LOGIN]);
        }
        return 
$this;
    }
[/
FONT
El problema es el siguiente: siempre, no importa lo que ponga en el login. La vista SIEMPRE tira esto:

El password ingresado es incorrecto

Warning: mysqli::real_escape_string() expects parameter 1 to be string, object given in C:\xampp\htdocs\webteach\library\Zend\Db\Adapter\M ysqli.php on line 115


Alguien me podria dar una mano?
Gracias
Saludos !