Users table for login

For a historical reason, the table that contains the users to my app is called Youmans. I want to keep it that way. When I set up authentication all goes well until I put in the email and password and submit. At that point, I get an error message

Table class for alias Users could not be found

I have dug around in the forums here and only found one post that asked this question. that post was answered in a sort of snide way saying “why would you want to have a different table name” but did not deal with the issue at all.

I have also found some articles across the web with solutions but they seem to apply to an older version. one solution involved jiggering with the parameters to the functions where field names can be changed. In the current version this happens in $authenticationService->loadAuthenticator . applying this change brought a 500 error. The other solution I found suggested that so long as models existed named UsersTable and Users these could of course apply to a different table via $this->setTable(“Youmans”) . i did this and it dos not work.

Hoping someone can provide some insight as to how to use a different table name versus Users. Changing the table name will be difficult at best. Likely it would be easier at this point to change framework or jigger my own authentication system

What version of CakePHP are you using, and are you using the old Auth component (e.g. $this->Auth-> calls in your controllers) or the new plugins (e.g. $this->Authentication-> calls)? Any users plugin, like the CakeDC one, in place?

Hi, I have the same problem.
I use cake php 4 and Authentication plug-in and JWT.
I changed the table from User to another one setting userModel property in resolver. The login is ok but when I try to get identity cake use table Users and so I receive 401 error.
Anyone have suggestion?
Donatella

Thanks for the reply

I did figure this out

I am using the 4.x and the new authentication, no plugins.

I have posted my solution as a reply to my own message

Just thought I would loopback that I did find a solution.

in src/Application.php

In the getAuthenticationService function

use the resolver option as an array such as

$authenticationService->loadIdentifier(‘Authentication.Password’, [
‘resolver’ => [
‘className’ => ‘Authentication.Orm’,
‘userModel’ => ‘yourtablename’,
],
‘fields’ => [
‘username’ => ‘email’,
‘password’ => ‘password’,
],

]);