
Untitled
By: a guest on
Jun 9th, 2012 | syntax:
None | size: 0.65 KB | hits: 24 | expires: Never
kohana2 auth - login problem
ORM::factory('user', $post['username'])
<?php
// grab relevant $_POST data
$username = $this->input->post('username');
$password = $this->input->post('password');
// instantiate User_Model and set attributes to the $_POST data
$user = ORM::factory('user');
$user->username = $username;
$user->password = Auth::instance()->hash_password($password);
// if the user was successfully created...
if ($user->add(ORM::factory('role', 'login')) AND $user->save()) {
// login using the collected data
Auth::instance()->login($username, $password);
// redirect to somewhere
url::redirect('user/profile');
}