Reputation: 8982
Can someone help me understand this.
The AuthComponent::user()
method only returns some basic information about the user, not the actual User object itself.
Coming from rails, I am used to a fully loaded current_user
object
If I wanted something similar, should I do a
$this->User->id = AuthComponent::user('id')
and use that? Or is there already a built in method I can use.
Thanks in advance.
Upvotes: 0
Views: 171
Reputation: 8982
I ended up doing something like this
# load current_user
$this->loadModel('User');
$this->User->id = AuthComponent::user('id');
$user = $this->User->read();
$this->set('current_user',$user);
Upvotes: 0
Reputation: 14798
If you scroll down a bit in the linked documentation you will see that as of CakePHP 2.2 you can now use Containable
in your Auth setup, so you could do something like this:
public $components = array(
'Auth' => array(
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'email'),
'contain' => array('RelatedModel', 'RelatedModel')
)
)
)
);
Upvotes: 2