Me está costando aprender zend, deseo realizar autenticación de usuario y el error que tengo es este
Cita:
mi controlador es este 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
Código PHP:
Ver original
class LoginController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $this->view->form = $this->getForm (); // $this->view->form = $this->loginAction(); } public function getForm() { 'action' => '/login/process', 'method' => 'post' ) ); } } public function preDispatch() { if (Zend_Auth::getInstance ()->hasIdentity ()) { // If the user is logged in, we don't want to show the login form; // however, the logout action should still be available if ('logout' != $this->getRequest ()->getActionName ()) { $this->_helper->redirector ( 'index', 'index' ); } } else { // If they aren't, they can't logout, so that action should // redirect to the login form if ('logout' == $this->getRequest ()->getActionName ()) { $this->_helper->redirector ( 'index' ); } } } public function processAction() { $request = $this->getRequest (); // Check if we have a POST request if (! $request->isPost ()) { return $this->_helper->redirector ( 'index' ); } // Get our form and validate it $form = $this->getForm (); if (! $form->isValid ( $request->getPost () )) { // Invalid entries $this->view->form = $form; return $this->render ( 'index' ); // re-render the login form } // Get our authentication adapter and check credentials $adapter = $this->getAuthAdapter ( $form->getValues () ); $auth = Zend_Auth::getInstance (); $result = $auth->authenticate ( $adapter ); // / $values = $form->getValues (); $adapter = new Zend_Auth_Adapter_DbTable ( $this->db ); $adapter->setIdentity ( $values ['username'] )->setCredential ( $values ['password'] ); $auth = Zend_Auth::getInstance (); $result = $auth->authenticate ( $adapter ); /// if (! $result->isValid ()) { // Invalid credentials $form->setDescription ( 'Invalid credentials provided' ); $this->view->form = $form; return $this->render ( 'index' ); // re-render the login form } // We're authenticated! Redirect to the home page $this->_helper->redirector ( 'index', 'index' ); } public function logoutAction() { Zend_Auth::getInstance ()->clearIdentity (); $this->_helper->redirector ( 'index' ); // back to login page } }
por favor quisiera me expliquen el problema