开发者

Loading additional data for authenticated user with CakePHP Auth Component

开发者 https://www.devze.com 2023-03-01 16:01 出处:网络
I have some additional data I want to load on each request for the authenticated user. I recently adopted the Auth Component. Previously, I was loading this additional data in my AppController\'s befo

I have some additional data I want to load on each request for the authenticated user. I recently adopted the Auth Component. Previously, I was loading this additional data in my AppController's beforeFilter. I suppose I could leave it there and wrap the code within a test against $this->Auth->user();, but wanted to see if there were better way for both these items.

So the question is two part:

  • Is there a built in method of the Auth Component where I can load in additi开发者_运维问答onal data on each request for the authenticated user.
  • If not, is there a better way to do so than checking $this->Auth->user(); in the AppController's beforeFilter


  • no
  • few options
    • overloading auth component
    • roll your own
    • do the auth check, if they are logged in and the extra data is not around get it. it will obviously be an extra query, but its once per login... hardly a server killer.
0

精彩评论

暂无评论...
验证码 换一张
取 消