1

I want to use AuthComponent in CakePHP with a model (and its corresponding table) named Admin ('admins' table in the database). I've used $this->Auth->userModel = 'Admin'; as the documenation says in the BeforeFilter() function of the app_controller, to indicate that I'm not using the deafult model User.

However, either I'm doing it in the wrong place or there's something else that needs to be done, because I can't make the authentication to work (the login function in my admins_controller.php). The rest of functions work well (for example the add function).

If I use the name User for my model with a users table, it works perfectly. How do I fix this problem?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Albert R
  • 125
  • 5
  • 19
  • It can also be done with an array option of `'userModel' => 'Admin'` when you add `Auth` component to your controller – Yarek T Sep 07 '12 at 18:00

1 Answers1

2

Make sure you call parent::beforeFilter() in your AdminController::beforeFilter().

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
benjamin
  • 2,185
  • 1
  • 14
  • 19