I request help with the following please:
I need to add a field to the authentication system and allow me to validate it with the isValid() function when calling
$result = $this->Authentication->getResult();
if ($result->isValid()) {
....code
}
I have tried the following but it doesn’t work:
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
{
// Crea una nueva instancia de servicio de autenticación, definiendo la URL donde se debe
// redireccionar en caso de que se pretenda entrar a una vista protegida.
$authenticationService = new AuthenticationService([
'unauthenticatedRedirect' => '/'.basename(ROOT).'/users/login',
'queryParam' => 'redirect',
]);
// Carga los campos identificadores (logueo).
// Asegúrese de relacionar los campos con los que se valida el logueo
$authenticationService->loadIdentifier('Authentication.Password', [
'fields' => [
'username' => 'usuario',
'password' => 'password',
],
'where' => [ 'estado' => 'Activo' ], // This is the other field that i need to validate
]);
// 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' => 'usuario',
'password' => 'password',
],
'loginUrl' => '/'.basename(ROOT).'/users/login',
]);
return $authenticationService;
}