I have made a custom driver 'Auth_MyDriver' that extends Auth
I looked here how to: http://kohanaframework.org/3.2/guide/auth/driver/develop
And did so that when using this driver, it grab/logins the user from "test_users
" instead of "users
"
Now, when I use the custom driver "MyDriver
" the Auth::instance()->get_user()
it returns a string with the username
.
When I use the default "orm
" auth driver and call Auth::instance()->get_user()
it returns a whole object with the user data all grabbed from the users table, so you are able to call e.g Auth::instance()->get_user()->email
How can I make my custom driver work like the default orm auth driver, except that it should just look for test_* tables instead (test_users, test_roles, test_roles_users)
I spent hours on trying to find out, and I think its something about a Model User, that I need for my custom driver in order to do this ?
Hope for any help thanks!
Update:
My MyDriver, has the same method as the Auth File driver
public function get_user($default = NULL)
{
return $this->_session->get($this->_config['session_key'], $default);
}
Finally:
I simply grabbed the user from the database, turned into an object and send with complete_login:
$user = DB::select()->from($table_name)
->where('username', '=', $username)
->as_object()->execute()->current();
if(!empty($user))
{
if($password == $user->password)
{
return $this->complete_login($user);
}
}
This will do it :-)