Magento 2 – Modify authentication-popup.html Form Action

customerjavascriptmagento2overrides

Authentication popup is the login popup that will appear if customer who are not logged in press Proceed to Checkout button in cart page.

For default, when customer sign in using authentication popup they will be redirected to the previous page (cart page).

I want to modify the redirect url after customer sign in from authentication pop up, they'll redirected to custom page. I have trying to locate the form action in Magento_Customer/view/frontend/web/js/view/authentication-popup.js but i can't find it.

Best Answer

Your path should be : app/design/frontend/Vendor/Theme/Magento_Customer/web/js/view/authentication-popup.js

For the simple way, we can set the redirect url in our custom js - authentication-popup.js:

        /** Provide login action */
        login: function (loginForm) {

          ...... 
                this.isLoading(true);
                loginAction(loginData, null, false); // We can set the redirect here
          ......
        }

Take the look the loginAction method - Magento_Customer/js/action/login.

                   if (redirectUrl) {
                        window.location.href = redirectUrl;
                    } else if (response.redirectUrl) {
                        window.location.href = response.redirectUrl;
                    } else {
                        location.reload();
                    }

As we can see, if we set the redirect url by default, Magento site will use it for redirecting.

For the redirect Url, we can read more here: https://magento.stackexchange.com/a/131227/33057

Related Topic