Auth question - Use a controller other than UserController



In my database I have an employees table instead of a users table. I have been able to get logins to work when I create a user table and all the associates files as per the tutorial.

I was wondering if:
- is it a best practice to use a table called user
- Do I absolutely have to use a UserController or can I reference something else?

Sorry if this is an easy question (or one that is answered else where that I didn’t find)




I see I can specify this as per this:

I tried adding the following to my AppController.php :

// Simple setup $this->Auth->config(‘authenticate’, [‘Form’]); // Pass settings in $this->Auth->config(‘authenticate’, [ ‘Basic’ => [‘userModel’ => ‘Members’], ‘Form’ => [‘userModel’ => ‘Members’] ]);

After doing that I get the error

[ Deprecated (16384)](javascript:void(0);): Cake\Controller\Component\AuthComponent::config() is deprecated. Use setConfig()/getConfig() instead. - /var/www/html/timetracker/src/Controller/AppController.php, line: 61 You can disable deprecation warnings by setting Error.errorLevel to E_ALL & ~E_USER_DEPRECATED in your config/app.php. [ CORE/src/Core/functions.php , line 310 ]

I feel like I am close :frowning:


Aside from the deprecation warning, you have to set the loginAction to point to your controller (Employees?), the userModel too. Then you can have an action login in EmployeesController

AFAIK you can’t have 2 controllers for login, is either UsersController or EmployeesController


That makes sense. I’ll give that a try.