I'm working on integrating authentication and authorization into my CakePHP application now and am having some difficulties.
First up, I'm not using ACL. It scares me.
In my AppController I have this:
var $components = array("Auth");
So, any time I want to check the logged in user, I call this from one of my controllers:
And I get an array which is the information from my
usrs table (my table is called
usrs with model
The issue is that I'll often want to call functions on the
Usr model, so I have to do this in my controller:
$usr = ClassRegistry::init('Usr'); $usrInfo = $this->Auth->user(); $usr->set($usrInfo); // -- or -- $usr = ClassRegistry::init('Usr'); $usrId = $this->Auth->user('id'); $usr->id = $usrId;
This doesn't seem very cakey and it's been bugging me since I know there must be a better way. Should I add
var $uses = array("Usr") into my AppController so I don't have to use the ClassRegistry all the time? What's the best way to do this?