Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Kohana][v3] problem z auth
terabit
post
Post #1





Grupa: Zarejestrowani
Postów: 170
Pomógł: 4
Dołączył: 11.08.2006

Ostrzeżenie: (10%)
X----


Witam

Mój kod:

  1. public function action_addUser() {
  2.  
  3. $user = ORM::factory('user');
  4. $user->username = 'mmm';
  5. $user->email = 'mmm@gmail.com';
  6. $user->password = 'mmm';
  7.  
  8. if ($user->check())
  9. {
  10. $user->save();
  11. // dont forget to add roles. 'login' role needs for successful login
  12. $user->add('roles', ORM::factory('role', array('name' => 'admin')));
  13. $user->add('roles', ORM::factory('role', array('name' => 'login')));
  14. // redirect somewhere
  15.  
  16. }
  17. else
  18. {
  19. // get errors
  20. $errors = $user->validate()->errors('validate');
  21. // show registration form with errors or smth else
  22. }
  23.  
  24. }
  25.  
  26.  
  27. public function action_login() {
  28.  
  29. $auth = Auth::instance();
  30. if ($auth->login('admin', 'admin'))
  31. {
  32. echo 'hello, '.$auth->get_user()->username;
  33. }
  34. else
  35. {
  36. echo 'login failed!';
  37. }
  38.  
  39.  
  40. }


problem w tym ze tworzy tylko wpisy w tabeli 'role', nie dodaje nowego użytkownika do 'users',
po dodaniu użytkownika recznie, haslo w md5 (może nie ma być md5?) nie chce przejść autoryzacji... :/

orm, auth, oauth w bootstrapie wlaczone winksmiley.jpg

dodatkowo gdyby był potrzebny schemat bazy danych - http://docs.kohanaphp.com/addons/auth#mysql_schema

Z góry dzięki za pomoc

Ten post edytował terabit 21.01.2011, 15:42:27


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.08.2025 - 14:45