Witam, mam pewien skrypt, w którym potrzebuję dostać się do panelu admina, w aplication.ini mam:

  1. resources.router.routes.administracja.route = "/administracja"
  2. resources.router.routes.administracja.defaults.controller = "/autoryzacja"
  3. resources.router.routes.administracja.defaults.action = "/index"



w AutoryzacjaController.php:

  1. <?php
  2.  
  3. class AutoryzacjaController extends Zend_Controller_Action
  4. {
  5.  
  6. public function indexAction()
  7. {
  8. $this->view->form = new Application_Form_Login();
  9. }
  10.  
  11. public function loginAction()
  12. {
  13. $this->_helper->viewRenderer('index');
  14. $form = new Application_Form_Login();
  15. if ($form->isValid($this->getRequest()->getPost())){
  16. $adapter = new Zend_Auth_Adapter_DbTable(
  17. null,
  18. 'user',
  19. 'uzytkownik',
  20. 'haslo',
  21. 'MD5(CONCAT(?))'
  22. );
  23. $adapter->setIdentity($form->getValue('uzytkownik'));
  24. $adapter->setCredential($form->getValue('haslo'));
  25. $auth = Zend_Auth::getInstance();
  26. $result = $auth->authenticate($adapter);
  27. if ($result->isValid()){
  28. return $this->_helper->redirector(
  29. 'index',
  30. 'index',
  31. 'default'
  32. );
  33. }
  34. $form->haslo->addError('Błędna próba logowania');
  35. }
  36. $this->view->form = $form;
  37.  
  38. }
  39.  
  40. public function logoutAction()
  41. {
  42. $auth = Zend_Auth::getInstance();
  43. $auth->clearIdentity();
  44. return $this->_helper->redirector(
  45. 'index',
  46. 'index',
  47. 'default'
  48. );
  49. }
  50.  
  51.  
  52. }
  53.  
  54.  
  55.  


i w widoku autoryzacja mam:

  1. <?php
  2. $auth = Zend_Auth::getInstance();
  3. if (!$auth->hasIdentity())
  4. echo $this->form;
  5. else
  6. echo "Jesteś już zalogowany";
  7. ?>
  8.  


Dane w bazie są następujące:

uzytkownik: admin

haslo: 21232f297a57a5a743894a0e4a801fc3 -> to w md5 to jest admin czyli hasło i login powinno być admin, jednak jak tak wpisuję to nie działa, nie wyskakuje również komunikat o niepoprawnych danych, a powinien



jeszcze plik forms/Login.php

  1. <?php
  2.  
  3. class Application_Form_Login extends Zend_Form {
  4.  
  5. public function init() {
  6. $this->setMethod('post');
  7. $view = Zend_Layout::getMvcInstance()->getView();
  8. $url = $view->url(array('controller' => 'autoryzacja', 'action' => 'login'));
  9. $this->setAction($url);
  10. $this->addElement(
  11. 'text', 'uzytkownik', array('label' => 'Uzytkownik:',
  12. 'required' => true,
  13. 'filters' => array('StringTrim'),
  14. )
  15. );
  16. $this->addElement(
  17. 'password', 'haslo', array('label' => 'Hasło:',
  18. 'required' => true,
  19. )
  20. );
  21. $this->addElement(
  22. 'submit', 'submit', array('ignore' => true,
  23. 'label' => 'Zaloguj',
  24. )
  25. );
  26. }
  27.  
  28. }
  29.