Skip to content

More issues related to the customer data loaded by js #30498

Closed
@pitbulk

Description

@pitbulk

Description

In ticket #28428 I reported a bug that affected customer data not retrieved after executing a custom login controller, that was fixed by: #29081

One of my customers reported 2 more different bugs that I consider are related with the customer data loaded by javascript as well

  • If in the Magento instance exists customers with similar fullname (same lastname for example), the message that appears on the welcome message mismatch the fullname (wrong is loaded). It was verified that the data of the logged user that appears on the profile view is different than the one loaded on the customer data object loaded by js for printing the welcome message

  • After login, if the user proceeds to checkout, the login popup appear even if the user was previously logged.
    Similar than the issue described here: https://github.com/mageplaza/magento-2-social-login/issues/197

On 2.4.1 and 2.4.2 a new issue appeared as well:

  • After login, I can access user account and verify Im logged in, after that I add a new item to the cart, ans when visiting the cart, the login auth popup appears. It seems that something is wrong with the user session on the frontend.

Preconditions

  • Magento 2.3.4, 2.3.5, 2.4, 2.4.1
  • Custom Login controller

My login controller is similar than the PostLogin code

$customerSession->setCustomerDataAsLoggedIn($customer);
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
    $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
    $metadata->setPath('/');
    $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
}

$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setUrl($targetURL);

The extension also forces sections to be invalidated after my custom login, by adding a etc/frontend/sections.xml as documented on page-caching

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="sso/saml2/acs">
        <section name="*"/>
    </action>
</config>

Steps to reproduce

I implemented this simple custom login controller that will allow reproducing the issue:
https://github.com/pitbulk/magento-custom-login

If in a private browser I log in with a user that has the same lastname as others, I experience the issues described.

The issue exists on Magento 2.3.4, 2.3.4-p2, 2.3.5-p1 and 2.4.1

Expected result

  • customer data properly loaded even if existing customer accounts with the same lastname
  • If the user is logged in, clicking on the checkout link will never open a popup for authentication

Actual result

After enabling a private browser, and log in

Metadata

Metadata

Assignees

Labels

Issue: needs updateAdditional information is require, waiting for responseReported on 2.3.4Indicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions