Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-customer
Controller
Account
ForgotPasswordPost.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Customer\Controller\Account
;
8
9
use
Magento\Framework\App\Action\HttpPostActionInterface
as HttpPostActionInterface;
10
use
Magento\Customer\Api\AccountManagementInterface
;
11
use
Magento\Customer\Model\AccountManagement
;
12
use
Magento\Customer\Model\Session
;
13
use
Magento\Framework\App\Action\Context
;
14
use
Magento\Framework\Escaper
;
15
use
Magento\Framework\Exception\NoSuchEntityException
;
16
use
Magento\Framework\Exception\SecurityViolationException
;
17
22
class
ForgotPasswordPost
extends
\Magento\Customer\Controller\AbstractAccount
implements
HttpPostActionInterface
23
{
27
protected
$customerAccountManagement
;
28
32
protected
$escaper
;
33
37
protected
$session
;
38
45
public
function
__construct
(
46
Context
$context,
47
Session
$customerSession,
48
AccountManagementInterface
$customerAccountManagement
,
49
Escaper
$escaper
50
) {
51
$this->session = $customerSession;
52
$this->customerAccountManagement =
$customerAccountManagement
;
53
$this->escaper =
$escaper
;
54
parent::__construct($context);
55
}
56
62
public
function
execute
()
63
{
65
$resultRedirect = $this->resultRedirectFactory->create();
66
$email
= (string)$this->
getRequest
()->getPost(
'email'
);
67
if
(
$email
) {
68
if
(!\
Zend_Validate::is
(
$email
, \
Magento
\Framework\
Validator
\EmailAddress::class)) {
69
$this->session->setForgottenEmail(
$email
);
70
$this->messageManager->addErrorMessage(
71
__
(
'The email address is incorrect. Verify the email address and try again.'
)
72
);
73
return
$resultRedirect->setPath(
'*/*/forgotpassword'
);
74
}
75
76
try
{
77
$this->customerAccountManagement->initiatePasswordReset(
78
$email
,
79
AccountManagement::EMAIL_RESET
80
);
81
}
catch
(NoSuchEntityException $exception) {
82
// Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
83
}
catch
(SecurityViolationException $exception) {
84
$this->messageManager->addErrorMessage($exception->getMessage());
85
return
$resultRedirect->setPath(
'*/*/forgotpassword'
);
86
}
catch
(\Exception $exception) {
87
$this->messageManager->addExceptionMessage(
88
$exception,
89
__
(
'We\'re unable to send the password reset email.'
)
90
);
91
return
$resultRedirect->setPath(
'*/*/forgotpassword'
);
92
}
93
$this->messageManager->addSuccessMessage($this->
getSuccessMessage
(
$email
));
94
return
$resultRedirect->setPath(
'*/*/'
);
95
}
else
{
96
$this->messageManager->addErrorMessage(
__
(
'Please enter your email.'
));
97
return
$resultRedirect->setPath(
'*/*/forgotpassword'
);
98
}
99
}
100
107
protected
function
getSuccessMessage
(
$email
)
108
{
109
return
__
(
110
'If there is an account associated with %1 you will receive an email with a link to reset your password.'
,
111
$this->escaper->escapeHtml(
$email
)
112
);
113
}
114
}
Magento\Customer\Controller\Account\ForgotPasswordPost\$customerAccountManagement
$customerAccountManagement
Definition:
ForgotPasswordPost.php:27
Magento\Framework\Exception\SecurityViolationException
Definition:
SecurityViolationException.php:14
Magento\Customer\Model\Session
Definition:
Storage.php:8
$email
$email
Definition:
details.phtml:13
Magento\Customer\Model\AccountManagement\EMAIL_RESET
const EMAIL_RESET
Definition:
AccountManagement.php:149
Magento\Customer\Model\AccountManagement
Definition:
AccountManagement.php:64
Magento\Customer\Controller\Account\ForgotPasswordPost\getSuccessMessage
getSuccessMessage($email)
Definition:
ForgotPasswordPost.php:107
__
__()
Definition:
__.php:13
Magento\Framework\Escaper
Definition:
Escaper.php:15
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
Magento\Framework\App\ActionInterface\execute
execute()
Magento\Customer\Controller\Account\ForgotPasswordPost
Definition:
ForgotPasswordPost.php:22
Magento\Customer\Model\Session
Definition:
Session.php:22
Magento\Customer\Controller\Account\ForgotPasswordPost\$session
$session
Definition:
ForgotPasswordPost.php:37
Magento\Customer\Controller\Account\ForgotPasswordPost\__construct
__construct(Context $context, Session $customerSession, AccountManagementInterface $customerAccountManagement, Escaper $escaper)
Definition:
ForgotPasswordPost.php:45
Magento
Magento\Framework\App\Action\HttpPostActionInterface
Definition:
HttpPostActionInterface.php:16
Magento\Customer\Controller\Account
Definition:
Confirm.php:7
Magento\Customer\Controller\Account\ForgotPasswordPost\$escaper
$escaper
Definition:
ForgotPasswordPost.php:32
Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator
Definition:
TierPrice.php:6
Zend_Validate\is
static is($value, $classBaseName, array $args=array(), $namespaces=array())
Definition:
Validate.php:195
Magento\Framework\App\Action\Context
Definition:
Context.php:24
Magento\Customer\Api\AccountManagementInterface
Definition:
AccountManagementInterface.php:17
Magento\Customer\Controller\AbstractAccount
Definition:
AbstractAccount.php:16
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16