1

I have created a new page on which I'd like my users to be able to login in via. All works well when the user enters valid information (they're logged in successfully), but if they enter the wrong email / password, they are redirected to the /customer/account/login/ page. It is on this page that they're then shown the 'Invalid login or password' message in the the messages bar at the top of the page.

I'd obviously like the validation messages to appear at the top of my new page and not redirect the user. I thought that if I included the page.messages container and the blocks within it, it would work. Unfortunately, it doesn't. Any ideas?

Here's a section of the xml for my new page:

<container name="newpage.login.container" htmlTag="div" htmlId="newpage-login-wrapper">
    <container name="page.messages.newpage" htmlTag="div" htmlClass="page messages">
        <block class="Magento\Framework\View\Element\Template" name="ajax.message.placeholder.newpage" template="Magento_Theme::html/messages.phtml"/>
        <block class="Magento\Framework\View\Element\Messages" name="messages.newpage" as="messages" template="Magento_Theme::messages.phtml"/>
    </container>                
    <block class="Magento\Customer\Block\Form\Login" name="customer_form_login_checkout" template="Magento_Customer::form/login.phtml">
        <container name="form.additional.info" as="form_additional_info"/>
    </block>
</container>

The messages container and its content appears on the page, but it does nothing and the page is still redirected when the user tries to log in with incorrect details.

1

First of all you have to remove redirection if credentials are invalid. Maybe create plugin on login controller which procces your login data. You can try to create some plugin for example redirecting to referer in case of bad credentials. Then you will see if message is shown. If not you can think about next steps.

| improve this answer | |
  • I know how to update the redirect URL once a user logs in successfully ($this->customerSession->setAfterAuthUrl($this->redirectUrl)) but how do I update the failed login URL? – Mitch7663 Nov 11 '16 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.