-
Notifications
You must be signed in to change notification settings - Fork 333
Description
When form validation fails, for example when a user enters an invalid email address on the login for this piece of code executes
https://github.com/ZF-Commons/ZfcUser/blob/3.x/src/ZfcUser/Controller/UserController.php#L120
flashMessenger is used to set the error and the user is redirected back to the login form.
Looking in the Login controller action
https://github.com/ZF-Commons/ZfcUser/blob/3.x/src/ZfcUser/Controller/UserController.php#L94
there is nothing that handles the flash messenger error. I rectified this by overriding the login view script login.phtml - https://github.com/ZF-Commons/ZfcUser/blob/3.x/view/zfc-user/user/login.phtml
and adding the following code
<?php if ($this->flashMessenger()->setNamespace('zfcuser-login-form')->hasMessages()) :
$messages = $this->flashMessenger()->setNamespace('zfcuser-login-form')->getMessages();
foreach ($messages as $message) { ?>
<div class="alert alert-error">
<?php echo $message; ?>
</div>
<?php } ?>
<?php endif; ?>
I can submit a PR for this I just wanted to make sure first I haven't overlooked something and the fact this isn't an actual bug that the error is not displayed.
Another implementation idea might be to use the actual zend form error messages as this tells the user what is wrong. Currently the error just says
Authentication failed. Please try again.
But if a user enters an invalid email address it might be worth telling them. Happy to try and submit a PR for this just thought it worth discussing implementation first.