Я тестирую аутентификацию входа в cakephp 4. Я скопировал весь код из аутентификации учебника cakephp4 (см. ссылку ниже) и скопировал весь код в свой проект по мере необходимости, и ошибок не было обнаружено.
я могу создавать новые логины, но я все еще не могу войти в систему. Мой проект cakephp4 приведен ниже (это всего лишь тестовый проект, использующий тестовые данные, чтобы попытаться заставить работать логины)
https://southernservices.com.au/crm4/users/login
This is the code where things get stuck
public function login()
{
$this->request->allowMethod(['get', 'post']);
$result = $this->Authentication->getResult();
// regardless of POST or GET, redirect if user is logged in
debug($result); //debug of output
if ($result->isValid()) {
// redirect to /articles after login success
$redirect = $this->request->getQuery('redirect', [
'controller' => 'Articles',
'action' => 'index',
]);
$this->Flash->success(__('Logged In!'));
return $this->redirect($redirect);
}
// display error if user submitted and authentication failed
if ($this->request->is('post') && !$result->isValid()) {
$this->Flash->error(__('Invalid username or password'));
}
}
in application.php here is the main function for authentication
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
{
$authenticationService = new AuthenticationService([
'unauthenticatedRedirect' => '/users/login',
'queryParam' => 'redirect',
]);
// Load identifiers, ensure we check email and password fields
$authenticationService->loadIdentifier('Authentication.Password', [
'fields' => [
'username' => 'email',
'password' => 'password',
]
]);
// Load the authenticators, you want session first
$authenticationService->loadAuthenticator('Authentication.Session');
// Configure form data check to pick email and password
$authenticationService->loadAuthenticator('Authentication.Form', [
'fields' => [
'username' => 'email',
'password' => 'password',
],
'loginUrl' => '/users/login',
]);
return $authenticationService;
}
https://book.cakephp.org/4/en/tutorials-and-examples/cms/authentication.html