Skip to content

Added password reset service email config. Using this config for gett… #32883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/code/Magento/Security/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Config implements ConfigInterface
const XML_PATH_MIN_TIME_BETWEEN_PASSWORD_RESET_REQUESTS = 'min_time_between_password_reset_requests';

/**
* Recipient email config path
* Configuration key to password reset service email
*/
const XML_PATH_EMAIL_RECIPIENT = 'contact/email/recipient_email';
const XML_PATH_PASSWORD_RESET_SERVICE_EMAIL = 'password_reset_service_email';

/**
* @var ScopeConfigInterface
Expand Down Expand Up @@ -93,7 +93,7 @@ public function __construct(
public function getCustomerServiceEmail()
{
return $this->scopeConfig->getValue(
self::XML_PATH_EMAIL_RECIPIENT,
$this->getXmlPathPrefix() . self::XML_PATH_PASSWORD_RESET_SERVICE_EMAIL,
StoreScopeInterface::SCOPE_STORE
);
}
Expand Down
20 changes: 18 additions & 2 deletions app/code/Magento/Security/Test/Unit/Model/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,38 @@ public function testGetLimitationTimePeriod()
/**
* Test get customer service email
* @return void
* @dataProvider dataProviderForGetCustomerServiceEmail
*/
public function testGetCustomerServiceEmail()
public function testGetCustomerServiceEmail($scope)
{
$email = 'test@example.com';
$this->scopeConfigMock->expects($this->once())
->method('getValue')
->with(
Config::XML_PATH_EMAIL_RECIPIENT,
$this->getXmlPathPrefix($scope)
. Config::XML_PATH_PASSWORD_RESET_SERVICE_EMAIL,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
->willReturn(
$email
);
$this->scopeMock->expects($this->once())
->method('getCurrentScope')
->willReturn($scope);
$this->assertEquals($email, $this->model->getCustomerServiceEmail());
}

/**
* @return array
*/
public function dataProviderForGetCustomerServiceEmail()
{
return [
[Area::AREA_ADMINHTML],
[Area::AREA_FRONTEND]
];
}

/**
* Test get admin session lifetime
* @return void
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Security/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<field id="password_reset_protection_type" separator="," negative="1">0</field>
</depends>
</field>
<field id="password_reset_service_email" translate="label comment" type="text" sortOrder="9" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Password Reset Service Email</label>
<comment>Service email address for password reset communication</comment>
<validate>validate-email</validate>
</field>
</group>
</section>
<section id="customer">
Expand All @@ -58,6 +63,11 @@
<field id="password_reset_protection_type" separator="," negative="1">0</field>
</depends>
</field>
<field id="password_reset_service_email" translate="label comment" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Password Reset Service Email</label>
<comment>Service email address for password reset communication</comment>
<validate>validate-email</validate>
</field>
</group>
</section>
</system>
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Security/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
<max_number_password_reset_requests>5</max_number_password_reset_requests>
<min_time_between_password_reset_requests>10</min_time_between_password_reset_requests>
<session_lifetime>900</session_lifetime>
<password_reset_service_email><![CDATA[hello@example.com]]></password_reset_service_email>
</security>
</admin>
<customer>
<password>
<password_reset_protection_type>1</password_reset_protection_type>
<max_number_password_reset_requests>5</max_number_password_reset_requests>
<min_time_between_password_reset_requests>10</min_time_between_password_reset_requests>
<password_reset_service_email><![CDATA[hello@example.com]]></password_reset_service_email>
</password>
</customer>
</default>
Expand Down