Witam.

Mam bardzo dziwny problem z logowaniem. Mam 2 kontrolery: Login i Index. Jak się można domyśleć pierwszy jest aktywny gdy się logujemy i w wypadku powodzenia przekierowuje do drugiego. Niestety w przypadku poprawnych danych przekierowuje mnie z powrotem na stronę logowania. Nigdzie nie mam aktywnego przekierowania na stronę logowania

  1. <?php defined('SYSPATH') or die('No direct script access.');
  2.  
  3. class Controller_Index extends Controller_Template {
  4.  
  5. public $template = "main/index";
  6.  
  7. public function before()
  8. {
  9. parent::before();
  10.  
  11. $this->template->menu = View::factory("main/menu");
  12. $this->template->content = View::factory("main/content");
  13.  
  14. //if(!$this->is_logged())
  15. // $this->redirect('login');
  16.  
  17. $session = Session::instance();
  18.  
  19. $this->template->menu->user_data = $session->get('user_data');
  20. }
  21.  
  22. public function action_index()
  23. {
  24.  
  25. }
  26.  
  27. public function is_logged()
  28. {
  29. $session = Session::instance();
  30.  
  31. if($session->get('user_data')) {
  32. return true;
  33. }
  34.  
  35. return false;
  36. }
  37.  
  38. }
  39. ?>


  1. <?php defined('SYSPATH') or die('No direct script access.');
  2.  
  3. class Controller_Login extends Controller_Template {
  4.  
  5. public $template = "main/index";
  6. private $view;
  7. private $login;
  8.  
  9. public function before()
  10. {
  11. parent::before();
  12.  
  13. //if($this->is_logged()) {
  14. // $this->redirect('/');
  15. //}
  16.  
  17. $this->login = new Model_Login;
  18. $this->template->content = View::Factory("main/login");
  19. $this->view = &$this->template->content;
  20. $this->template->menu = '';
  21.  
  22. }
  23.  
  24. public function action_login()
  25. {
  26. $post = $this->request->post();
  27.  
  28. if($post) {
  29. try {
  30. if($this->login->log_in($post)) //zwraca true
  31. $this->redirect('/'); //nie dziala
  32. } catch(Exception $e) {
  33. $this->view->login_error = $e->getMessage();
  34. }
  35. }
  36.  
  37. }
  38.  
  39. public function action_logout()
  40. {
  41. $this->login->log_out();
  42. $this->redirect('login');
  43. }
  44.  
  45. public function is_logged()
  46. {
  47. $session = Session::instance();
  48.  
  49. if($session->get('user_data')) {
  50. return true;
  51. }
  52.  
  53. return false;
  54. }
  55. }
  56. ?>