Hello,
in a login form I have an email (required) and a password. I have 2 inputfilters, one for the email, the other for the password. The password Inputfilter has an Authentication Validator.
This is an example I made on a fresh install of Laminas MVC to reproduce the problem :
$factory = new Factory();
$service = new AuthenticationService();
$adapter = new Callback();
$adapter->setCallback(static function ($identity, $credential) {
return null;
});
$service->setAdapter($adapter);
$form = $factory->createForm([
'name' => 'authentication-form',
'elements' => [
'identity' => [
'spec' => [
'name' => 'identity',
'type' => 'email',
'options' => ['label' => 'Email :'],
],
],
'credential' => [
'spec' => [
'name' => 'credential',
'type' => 'password',
'options' => ['label' => 'Password :'],
],
],
'button-submit' => [
'spec' => [
'name' => 'button-submit',
'type' => 'button',
'attributes' => ['type' => 'submit'],
'options' => ['label' => 'Log in'],
],
],
],
'input_filter' => [
'identity' => [
'name' => 'identity',
'required' => true,
'break_on_failure' => true,
],
'credential' => [
'name' => 'credential',
'required' => true,
'validators' => [
Authentication::class => [
'name' => Authentication::class,
'options' => [
'identity' => 'identity',
'credential' => 'credential',
'service' => $service,
'adapter' => $adapter,
],
],
],
],
],
]);
$form->setData(['identity' => 'emailwrong', 'credential' => 'mypassword']);
if (!$form->isValid()) {
var_dump($form->getMessages());
}
I would like to stop the login process if the email is invalid. I put the credential InputFilter after the email one and I set ‘break_on_failure’ on the email InputFilter. But it doesn’t work, On the var_dump I have :
array(2) {
["identity"]=>
array(1) {
["regexNotMatch"]=>
string(114) "The input does not match against pattern '/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/'"
}
["credential"]=>
array(1) {
["general"]=>
string(21) "Authentication failed"
}
}
Did I miss something ?
Thank you in advance