Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [kohana] auth, logowanie, co robię źle?
wald3k
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 12.10.2010

Ostrzeżenie: (0%)
-----


Uczę się kohana 2.3.4, chcę zrobić logowanie i ale nie działa i nie wiem co robię źle. Mam taki kod:
  1. class Auth_Controller extends Home_Controller {
  2.  
  3. public function __construct()
  4. {
  5. parent::__construct();
  6. $this-> session = Session:: instance();
  7. $this-> auth = Auth :: instance();
  8. }
  9.  
  10. public function index()
  11. {
  12.  
  13. }
  14.  
  15. public function login()
  16. {
  17. if ($this->auth->logged_in())
  18. {
  19. url::redirect($this->session->get("requested_url"));
  20. echo '1';
  21. }
  22. else
  23. {
  24. if ($this->auth->logged_in()){
  25.  
  26. echo '2';
  27. }else{
  28. //$template->title="Please Login";
  29. $this->template = new View('template');
  30. $this->template->tresc= new View('login');
  31. $this->template->render(TRUE);
  32. echo '3';
  33.  
  34. }
  35. }
  36. }
  37.  
  38. public function login2() {
  39.  
  40. $username = $this->input->post('username');
  41. $password = $this->input->post('password');
  42. $user = ORM::factory('user', $username);
  43.  
  44. Auth::instance()->login($user->username, $password);
  45.  
  46.  
  47. echo html::anchor('auth/logout', 'wyloguj!');
  48.  
  49. if ($this->auth->logged_in())
  50. echo '4';
  51. else
  52. echo '5';
  53.  
  54. }
  55. }

  1. class Home_Controller extends Controller {
  2.  
  3. public $template;
  4. public $session;
  5. public $auth;
  6. public function __construct()
  7. {
  8. parent::__construct();
  9.  
  10. }
  11.  
  12. public function index()
  13. {
  14.  
  15. $this->template = new View('template');
  16. $this->template->tresc = new View('glowna/index');
  17. $this->template->render(TRUE);
  18.  
  19.  
  20. }
  21. }


Czy mógłby ktoś na to spojrzeć? Po logowaniu ten fragment
  1. if ($this->auth->logged_in())
  2. echo '4';
  3. else
  4. echo '5';
Ciągle zwraca 5, czyli chyba user nie jest zalogowany? Co robię źle że nie chce logować?
Dzięki za pomoc.

Jakby była potrzeba pokazać pliki widoków to napiszcie .

Ten post edytował wald3k 12.10.2010, 20:15:03
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.08.2025 - 15:11