Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message not displayed on failed login #670

Open
jeremyquinton opened this issue Jul 9, 2017 · 3 comments
Open

Error message not displayed on failed login #670

jeremyquinton opened this issue Jul 9, 2017 · 3 comments

Comments

@jeremyquinton
Copy link

jeremyquinton commented Jul 9, 2017

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.

@jarrettj
Copy link

jarrettj commented Nov 1, 2017

Can't get errors displaying as well.
+1

@koseduhemak
Copy link

koseduhemak commented Nov 30, 2017

@jeremyquinton
If I try your code it will display "authenication failed" message. But why do we not use messages array at login form class?
There are no form messages set.

@gkzsolt
Copy link

gkzsolt commented Jul 4, 2018

@jeremyquinton, thanks for your observations and workaround, they saved me a lot ;) Too bad that the developers seemed to have abandoned the project :(
From the UserController code I'd understand that the error messages are stored in the flashMessenger, to be taken from there in the phtml templates; so if this is not done, we'll have no error messages displayed. Curiously though, our login module worked with the ZF2 version of ZFcUser and got broken recently in ZF3, so I don't know how it worked and what they changed.
Yes, it would also be good to have different error messages, dare I say translatable? But apparently nobody cares from developers, the project is dead :(
I'll will get rid of this module as soon as I can - there are better ones around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants