magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Customer is logged in but showing 404 error in frontend. #35838

Closed ananth-iyer closed 5 months ago

ananth-iyer commented 2 years ago

Preconditions and environment

Base64 - aHR0cDovL21hZ2VudG8yNDAubG9jYWwvY3VzdG9tZXIvYWNjb3VudC9sb2dpblBvc3Qv Decoded Base64 - http://magento240.local/customer/account/loginPost/

Steps to reproduce

  1. Go to frontend.
  2. Add /customer/account/loginPost/ in your magento url. ex-http://magento240.local/customer/account/loginPost/
  3. Now click on {}S{}ign In 
  4. Give login id and password.

Expected result

It should generate referer url to Customer dashboard page when referer URL header contains /loginPost.

Actual result

It is not generating referrer url to customer dashboard page,It is showing 404 error page but customer is logged in.

Attached video: Untitled_ Jul 29, 2022 3_00 PM.webm

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @ananth-iyer. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

ananth-iyer commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @ananth-iyer. Thank you for your request. I'm working on Magento instance for you.

m2-assistant[bot] commented 2 years ago

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-deployment-service[bot] commented 2 years ago

Hi @ananth-iyer, here is your Magento Instance: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering Admin access: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering/admin_b432 Login: 3eb31f53 Password: 06218ec6c308

ananth-iyer commented 2 years ago

If you visit this link: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering/customer/account/loginPost/ Click on Sign In on above link so will get better idea

engcom-Lima commented 2 years ago

Hi @ananth-iyer

Thanks for your contribution and collaboration.

I have tried to reproduce the issue but unable to reproduce it. Kindly refer this video for your reference.Also, update your steps to reproduce if something you have missed in it. If possible please send video of this issue.It will be helpful to us.

Thanks

ananth-iyer commented 2 years ago

You did not click this link to replicate the issue - https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering/customer/account/loginPost/

It is clear, you don't want to fix the issue.

ananth-iyer commented 2 years ago

@engcom-Lima ☝🏻

engcom-Lima commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Lima, here is your Magento Instance: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering Admin access: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering/admin_3dc3 Login: ac208836 Password: 2adf4dfe1963

engcom-Lima commented 2 years ago

Hi @ananth-iyer ,

I had clicked on above url you have given and I got the 404 error as you described. Further I tried to investigate when we get this url appended with /loginPost. Inorder to identify the specific scenario I had followed your steps to reproduce and recorded above video. Can you please help answering whether you are updating url your own or any specific scenario we have to follow to get the url appended with /loginPost?

Thanks

ananth-iyer commented 2 years ago

@engcom-Lima It takes referer url /loginPost, encodes with base64 and adds in referer parameter of /login. So after success login, page is redirected to /loginPost

ananth-iyer commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @ananth-iyer. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @ananth-iyer, here is your Magento Instance: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering Admin access: https://70b0711c568e9cdf00416449ee01f393.instances.magento-community.engineering/admin_0ec3 Login: 89da8442 Password: 217a3ecdd1fa

ananth-iyer commented 2 years ago

@engcom-Lima check this screen recording Untitled_ Jul 29, 2022 3_00 PM.webm

engcom-Lima commented 2 years ago

:heavy_check_mark: Issue confirmed

Issue got reproduced in 2.4-develop branch.

Description: Customer is logged in but showing 404 error in the frontend. Pre-requisite: Fresh magento 2.4-develop should be installed.

Steps to reproduce:

  1. Go to frontend.
  2. Add /customer/account/loginPost/ in your magento url.
  3. Now click on sign In
  4. Give login id and password.

Expected result: It should generate referrer url to Customer dashboard page when referer URL header contains /loginPost.

Actual result: It is not generating referrer url to customer dashboard page,It is showing 404 error page but customer is logged in.

Screenshots: image

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6071 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

ananth-iyer commented 2 years ago

Hi @engcom-Lima are there any updates?

pmonosolo commented 2 years ago

I have the same issue, its also compounded by Amasty plugin redirecting all 404 pages to search making it confusing as hell.

This is still present on 2.4.5 upgrade from 2.4.3.

I think what happens is that after an unsuccesful login, it loses referrer URL or something similar happens and it just dumps the user to 404 page.

engcom-Lima commented 2 years ago

Hi @pmonosolo & @ananth-iyer ,

Thanks for your contribution and collaboration.

Internal team is working on it ,we will come back soon with some result.

Thanks

pmonosolo commented 2 years ago

Hi @pmonosolo & @ananth-iyer ,

Thanks for your contribution and collaboration.

Internal team is working on it ,we will come back soon with some result.

Thanks

Thanks @engcom-Lima !

It'd be great if the fix was released as a hotfix instead of waiting for a full release or a patch.

We cant have enterprise software have a serious issue where we lose customers because the basic function such as login does not work.

Vishrootways commented 1 year ago

We faced a similar issue in our one of the commerce cloud websites and the Adobe support team is not ready to check this so I am also actively looking for a solution.

In our case, the referer URL is incorrectly generated, and due to that customer is not redirecting to the previous page after login.

The issue is the login referer URL miss %2C at the end of the URL. Correct URL: https://www.our_domain.com/en/customer/account/login/referer/aHR0cHM6Ly93d3cucGFjaWZpY3Ntb2tlLmNvbS9lbi8%2C%2C/

Wrong URL: https://www.our_domain.com/en/customer/account/login/referer/aHR0cHM6Ly93d3cucGFjaWZpY3Ntb2tlLmNvbS9lbi8%2C/

As you can see, the correct URL has %2C at the end, which is missing in the wrong URL. (Basically, correct URL has two %2C%2C but the wrong URL only has one)

If we manually add %2C at the end of the URL, then it works as expected.

Now we are not sure why %2C is missing from the URL.

And the best thing is if we cloned the commerce cloud website to local (with same code and DB) then we have not face any issue :(

Thanks, Vish

ananth-iyer commented 1 year ago

@engcom-Lima are there any updates?

andriydeveloper commented 1 year ago

It happens everywhere where you have an exception during login. For example, you created a new customer account but did not verify the customer's email. Try to log in and you will get the link with the referer param. Then verify the customer email and finish login using the link with the referer param. Main bug in the file vendor/magento/module-customer/Model/Url.php, function getLoginUrlParams It makes referer using urlBuilder from
$referer = $this->urlBuilder->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]); but due to an exception, it generates to own controller: customer/account/loginPost

Quick solution until Magento developers make the right fix:

use Magento\Framework\Url\DecoderInterface; use Magento\Framework\Url\EncoderInterface; use Magento\Framework\UrlInterface;

/**
     * Fix Magento bug with customer logged in 404 referer url
     * https://github.com/magento/magento2/issues/35838
     *
     * @param  \Magento\Customer\Model\Url  $subject
     * @param $result
     * @return mixed
     */
    public function afterGetLoginUrlParams(
      \Magento\Customer\Model\Url $subject,
      $result
  ) {
        if(isset($result[\Magento\Customer\Model\Url::REFERER_QUERY_PARAM_NAME])){
          $referer = $result[\Magento\Customer\Model\Url::REFERER_QUERY_PARAM_NAME];
          $refererUrl = $this->urlDecoder->decode($referer);
          if(strpos($refererUrl, 'customer/account/loginPost')){
              $newReferer = $this->urlBuilder->getUrl('customer/account/index', ['_current' => true, '_use_rewrite' => true]);
              $result[\Magento\Customer\Model\Url::REFERER_QUERY_PARAM_NAME] = $this->urlEncoder->encode($newReferer);
          }
      }

      return $result;
  }