Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. kohana2 auth - login problem
  2. ORM::factory('user', $post['username'])
  3.        
  4. <?php
  5. // grab relevant $_POST data
  6. $username = $this->input->post('username');
  7. $password = $this->input->post('password');
  8.  
  9. // instantiate User_Model and set attributes to the $_POST data
  10. $user = ORM::factory('user');
  11. $user->username = $username;
  12. $user->password = Auth::instance()->hash_password($password);
  13.  
  14. // if the user was successfully created...
  15. if ($user->add(ORM::factory('role', 'login')) AND $user->save()) {
  16.  
  17.     // login using the collected data
  18.     Auth::instance()->login($username, $password);
  19.  
  20.     // redirect to somewhere        
  21.     url::redirect('user/profile');
  22. }