Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/01/2013, 08:12
wilmer30
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 11 meses
Puntos: 12
autenticación con zend

Hola:

Me está costando aprender zend, deseo realizar autenticación de usuario y el error que tengo es este

Cita:
Catchable fatal error: Argument 1 passed to Zend_Auth::authenticate() must be an instance of Zend_Auth_Adapter_Interface, null given, called in C:\xampp\htdocs\biblioteca\application\controllers \LoginController.php on line 62 and defined in C:\xampp\library\Zend\Auth.php on line 115
mi controlador es este
Código PHP:
Ver original
  1. class LoginController extends Zend_Controller_Action {
  2.    
  3.     public function init() {
  4.         /* Initialize action controller here */
  5.     }
  6.    
  7.     public function indexAction() {
  8.         $this->view->form = $this->getForm ();
  9.         // $this->view->form = $this->loginAction();
  10.     }
  11.     public function getForm() {
  12.         return new Application_Form_LoginForm ( array (
  13.                 'action' => '/login/process',
  14.                 'method' => 'post'
  15.         ) );
  16.     }
  17.    
  18.     public function getAuthAdapter(array $params) {
  19.     }
  20.    
  21.     public function preDispatch() {
  22.         if (Zend_Auth::getInstance ()->hasIdentity ()) {
  23.             // If the user is logged in, we don't want to show the login form;
  24.             // however, the logout action should still be available
  25.             if ('logout' != $this->getRequest ()->getActionName ()) {
  26.                 $this->_helper->redirector ( 'index', 'index' );
  27.             }
  28.         } else {
  29.             // If they aren't, they can't logout, so that action should
  30.             // redirect to the login form
  31.             if ('logout' == $this->getRequest ()->getActionName ()) {
  32.                 $this->_helper->redirector ( 'index' );
  33.             }
  34.         }
  35.     }
  36.     public function processAction() {
  37.         $request = $this->getRequest ();
  38.        
  39.         // Check if we have a POST request
  40.         if (! $request->isPost ()) {
  41.             return $this->_helper->redirector ( 'index' );
  42.         }
  43.        
  44.         // Get our form and validate it
  45.         $form = $this->getForm ();
  46.         if (! $form->isValid ( $request->getPost () )) {
  47.             // Invalid entries
  48.             $this->view->form = $form;
  49.             return $this->render ( 'index' ); // re-render the login form
  50.         }
  51.        
  52.         // Get our authentication adapter and check credentials    
  53.         $adapter = $this->getAuthAdapter ( $form->getValues () );
  54.         $auth = Zend_Auth::getInstance ();
  55.         $result = $auth->authenticate ( $adapter );
  56.             // /
  57.         $values = $form->getValues ();
  58.         $adapter = new Zend_Auth_Adapter_DbTable ( $this->db );
  59.         $adapter->setIdentity ( $values ['username'] )->setCredential ( $values ['password'] );
  60.         $auth = Zend_Auth::getInstance ();
  61.         $result = $auth->authenticate ( $adapter );    
  62.         ///
  63.         if (! $result->isValid ()) {
  64.             // Invalid credentials
  65.             $form->setDescription ( 'Invalid credentials provided' );
  66.             $this->view->form = $form;
  67.             return $this->render ( 'index' ); // re-render the login form
  68.         }
  69.        
  70.         // We're authenticated! Redirect to the home page
  71.         $this->_helper->redirector ( 'index', 'index' );
  72.     }
  73.     public function logoutAction() {
  74.         Zend_Auth::getInstance ()->clearIdentity ();
  75.         $this->_helper->redirector ( 'index' ); // back to login page
  76.     }
  77. }

por favor quisiera me expliquen el problema