-2

In my database I have the table

admins 
  - username
  - password

I want to log in users using this table.

When ever I try to login, it gives me an error:

sql error: unknown column Users.Username is not found 

Does CakePHP 3.x Auth only work with an users table?

Inigo Flores
  • 4,461
  • 1
  • 15
  • 36
Mithicher
  • 49
  • 2

1 Answers1

0

AuthComponent lets you specify a different userModel. Example:

// Pass settings in using 'all'
$this->Auth->config('authenticate', [
    AuthComponent::ALL => ['userModel' => 'Members'],
   'Basic',
   'Form'
]);

Please check the docs:

Inigo Flores
  • 4,461
  • 1
  • 15
  • 36
  • `$this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'fields' => [ 'username' => 'username', 'password' => 'password' ], 'userModel' => 'Admins' ] ]);` – Mithicher Jan 29 '16 at 07:26
  • Thanks for replying...if i have two login one for admins and one for users..do i need to create two separate AppController.php – Mithicher Jan 29 '16 at 07:35