After updating framework to 4 version, I want to migrate from AuthComponent
to AuthenticationCompoent
. But I have a problem with model name. How I can set custom user model for AuthenticationCompoent
, I’ve tried the following, but it is not work:
Application.php
$authenticationService->loadAuthenticator('Authentication.Form', [
'fields' => [
'username' => 'login',
'password' => 'password',
],
'loginUrl' => Router::url('managers/login'),
'userModel' => 'Managers'
]);
dirk
April 7, 2021, 11:12am
2
Maybe this could help:
https://book.cakephp.org/authentication/2/en/index.html
$authenticationService->loadAuthenticator(‘Authentication.Form’, [
‘fields’ => $fields,
‘loginUrl’ => Router::url([
‘prefix’ => false,
‘plugin’ => null,
‘controller’ => ‘Users’,
‘action’ => ‘login’,
]),
Fixed! Need to set in idenrifier:
Application.php
$authenticationService->loadIdentifier('Authentication.Password', [
'fields' => [
'username' => 'login',
'password' => 'password',
],
'resolver' => [
'className' => 'Authentication.Orm',
'userModel' => 'Managers',
'finder' => 'auth'
],
]);
1 Like