Search code examples
magento

Login module on Magento 2.3


Problem: I have a link on the home page. When a customer clicks on the link before login it needs to redirect to the login page and after the success of the log in the page needs to redirect to an X-URL URL. Otherwise needs to redirect to X-URL.

I did create a custom

app/code///view/fromtend/layout/customer_account_create.xml

on my custom module

and copy the login file and save it inside

app/code///view/fromtend/template/login.phtml

So currently the login interface is taken from the module. Then I set a flag Home page link named "raf=true"

then created a hidden input on the login page form and assign the value if "ref=true".

And I did check the "raf" value is true if the page redirect to X-URL otherwise defaults (LoginPost.php).

It is working for me. But

The form activities are handled by vendor file (default package file under vendor directory).

How can I resolve this in the proper way?


Solution

  • If I get you question correctly, you would like to modify \Magento\Customer\Controller\Account\LoginPost::execute.

    The best way to do this is to create a Plugin https://devdocs.magento.com/guides/v2.4/extension-dev-guide/plugins.html