Skip to content

Commit 542d3bc

Browse files
author
Joan He
authored
Merge pull request #4598 from magento-arcticfoxes/MC-17648
MC-17648: Registration email confirmation bugfix
2 parents e947753 + 3a1acc6 commit 542d3bc

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ protected function sendEmailConfirmation(CustomerInterface $customer, $redirectU
961961
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
962962
}
963963
$this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
964+
$customer->setConfirmation(null);
964965
} catch (MailException $e) {
965966
// If we are not able to send a new account email, this should be ignored
966967
$this->logger->critical($e);

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,21 @@ public function testGetCustomerActivateCustomer()
228228
'token' => $this->token
229229
]
230230
];
231-
$requestData = ['confirmationKey' => $this->customerData[CustomerInterface::CONFIRMATION]];
231+
232+
$requestData = ['confirmationKey' => CustomerHelper::CONFIRMATION];
232233
if (TESTS_WEB_API_ADAPTER === 'soap') {
233234
$requestData['customerId'] = 0;
234235
}
235-
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
236-
$this->assertEquals($this->customerData[CustomerInterface::ID], $customerResponseData[CustomerInterface::ID]);
237-
// Confirmation key is removed after confirmation
238-
$this->assertFalse(isset($customerResponseData[CustomerInterface::CONFIRMATION]));
236+
237+
try {
238+
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
239+
$this->assertEquals(
240+
$this->customerData[CustomerInterface::ID],
241+
$customerResponseData[CustomerInterface::ID]
242+
);
243+
} catch (\Exception $e) {
244+
$this->fail('Customer is not activated.');
245+
}
239246
}
240247

241248
/**

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,15 @@ public function testCreateCustomerWithoutOptionalFields()
249249
public function testActivateCustomer()
250250
{
251251
$customerData = $this->_createCustomer();
252-
$this->assertNotNull($customerData[Customer::CONFIRMATION], 'Customer activation is not required');
252+
253+
// Update the customer's confirmation key to a known value
254+
$customerData = $this->customerHelper->updateSampleCustomer(
255+
$customerData[Customer::ID],
256+
[
257+
'id' => $customerData[Customer::ID],
258+
'confirmation' => CustomerHelper::CONFIRMATION
259+
]
260+
);
253261

254262
$serviceInfo = [
255263
'rest' => [
@@ -265,16 +273,15 @@ public function testActivateCustomer()
265273

266274
$requestData = [
267275
'email' => $customerData[Customer::EMAIL],
268-
'confirmationKey' => $customerData[Customer::CONFIRMATION],
276+
'confirmationKey' => CustomerHelper::CONFIRMATION
269277
];
270278

271-
$result = $this->_webApiCall($serviceInfo, $requestData);
272-
273-
$this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!');
274-
$this->assertTrue(
275-
!isset($result[Customer::CONFIRMATION]) || $result[Customer::CONFIRMATION] === null,
276-
'Customer is not activated!'
277-
);
279+
try {
280+
$result = $this->_webApiCall($serviceInfo, $requestData);
281+
$this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!');
282+
} catch (\Exception $e) {
283+
$this->fail('Customer is not activated.');
284+
}
278285
}
279286

280287
public function testGetCustomerActivateCustomer()
@@ -294,14 +301,15 @@ public function testGetCustomerActivateCustomer()
294301
];
295302
$requestData = [
296303
'email' => $customerData[Customer::EMAIL],
297-
'confirmationKey' => $customerData[Customer::CONFIRMATION],
304+
'confirmationKey' => CustomerHelper::CONFIRMATION
298305
];
299306

300-
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
301-
302-
$this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]);
303-
// Confirmation key is removed after confirmation
304-
$this->assertFalse(isset($customerResponseData[Customer::CONFIRMATION]));
307+
try {
308+
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
309+
$this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]);
310+
} catch (\Exception $e) {
311+
$this->fail('Customer is not activated.');
312+
}
305313
}
306314

307315
public function testValidateResetPasswordLinkToken()

0 commit comments

Comments
 (0)