kohanakohana-3kohana-auth

Add table data to the logged in user


Using Kohana 3, I have my User table with a field that references a field from another table in the database, however, I can't find where the user data is requested so I can add a ->with to it so I can use it throughout the site.

I'm still digging around and these are the pieces I've found so far:

in: modules/orm/classes/Kohana/Auth/ORM.php

public function get_user($default = NULL)

it calls parent::get_user($default); so when I look up it’s parent: modules/auth/classes/Kohana/Auth.php:74, it's running this:

return $this->_session->get($this->_config['session_key'], $default);

$this->_session is created using:

Session::instance($this->_config['session_type']);

which I tracked down to: system/classes/Kohana/Session.php.

I think I reached a dead-end there.


I also tried doing a search for ORM::factory('User'), however, it's only used on login as far as I can tell.

get_user() returns an object of Model_User, but I'm not quite sure how to work with that to help me out.


Solution

  • The problem was coming from the fact that when you login, the data is cached and not pulled again until you re-login. So the tables needed to be joined on the login methods.