Skip to content

Commit 4921f45

Browse files
committed
MAGETWO-93628: Shopping cart is emptied after reset password procedure
1 parent d760607 commit 4921f45

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,11 @@ public function resetPassword($email, $resetToken, $newPassword)
702702
$customerSecure->setRpTokenCreatedAt(null);
703703
$customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
704704
$this->destroyCustomerSessions($customer->getId());
705-
$this->sessionManager->destroy(['send_expire_cookie' => false]);
705+
if ($this->sessionManager->isSessionExists()) {
706+
//delete old session and move data to the new session
707+
//use this instead of $this->sessionManager->regenerateId because last one doesn't delete old session
708+
session_regenerate_id(true);
709+
}
706710
$this->customerRepository->save($customer);
707711

708712
return true;

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,7 @@ function ($string) {
16071607
$this->customerSecure->expects($this->once())->method('setRpTokenCreatedAt')->with(null);
16081608
$this->customerSecure->expects($this->any())->method('setPasswordHash')->willReturn(null);
16091609

1610-
$this->sessionManager->expects($this->once())
1611-
->method('destroy')
1612-
->with(['send_expire_cookie' => false]);
1610+
$this->sessionManager->method('isSessionExists')->willReturn(false);
16131611
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
16141612
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
16151613
->disableOriginalConstructor()

lib/internal/Magento/Framework/Session/SessionManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ public function destroy(array $options = null)
353353
}
354354

355355
session_regenerate_id(true);
356+
session_destroy();
356357
if ($options['send_expire_cookie']) {
357358
$this->expireSessionCookie();
358359
}

0 commit comments

Comments
 (0)