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
ResetPasswordPost.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Customer\Controller\Account
;
7
8
use
Magento\Customer\Api\AccountManagementInterface
;
9
use
Magento\Customer\Api\CustomerRepositoryInterface
;
10
use
Magento\Customer\Model\Session
;
11
use
Magento\Framework\App\Action\Context
;
12
use
Magento\Framework\App\Action\HttpPostActionInterface
;
13
use
Magento\Framework\Exception\InputException
;
14
use
Magento\Customer\Model\Customer\CredentialsValidator
;
15
21
class
ResetPasswordPost
extends
\Magento\Customer\Controller\AbstractAccount
implements
HttpPostActionInterface
22
{
26
protected
$accountManagement
;
27
31
protected
$customerRepository
;
32
36
protected
$session
;
37
47
public
function
__construct
(
48
Context
$context,
49
Session
$customerSession,
50
AccountManagementInterface
$accountManagement
,
51
CustomerRepositoryInterface
$customerRepository
,
52
CredentialsValidator
$credentialsValidator =
null
53
) {
54
$this->session = $customerSession;
55
$this->accountManagement =
$accountManagement
;
56
$this->customerRepository =
$customerRepository
;
57
parent::__construct($context);
58
}
59
67
public
function
execute
()
68
{
70
$resultRedirect = $this->resultRedirectFactory->create();
71
$resetPasswordToken = (string)$this->
getRequest
()->getQuery(
'token'
);
72
$password = (string)$this->
getRequest
()->getPost(
'password'
);
73
$passwordConfirmation = (string)$this->
getRequest
()->getPost(
'password_confirmation'
);
74
75
if
($password !== $passwordConfirmation) {
76
$this->messageManager->addError(
__
(
"New Password and Confirm New Password values didn't match."
));
77
$resultRedirect->setPath(
'*/*/createPassword'
, [
'token'
=> $resetPasswordToken]);
78
79
return
$resultRedirect;
80
}
81
if
(iconv_strlen($password) <= 0) {
82
$this->messageManager->addError(
__
(
'Please enter a new password.'
));
83
$resultRedirect->setPath(
'*/*/createPassword'
, [
'token'
=> $resetPasswordToken]);
84
85
return
$resultRedirect;
86
}
87
88
try
{
89
$this->accountManagement->resetPassword(
90
null
,
91
$resetPasswordToken,
92
$password
93
);
94
$this->session->unsRpToken();
95
$this->messageManager->addSuccess(
__
(
'You updated your password.'
));
96
$resultRedirect->setPath(
'*/*/login'
);
97
98
return
$resultRedirect;
99
}
catch
(InputException $e) {
100
$this->messageManager->addError($e->getMessage());
101
foreach
($e->getErrors() as $error) {
102
$this->messageManager->addError($error->getMessage());
103
}
104
}
catch
(\Exception $exception) {
105
$this->messageManager->addError(
__
(
'Something went wrong while saving the new password.'
));
106
}
107
$resultRedirect->setPath(
'*/*/createPassword'
, [
'token'
=> $resetPasswordToken]);
108
109
return
$resultRedirect;
110
}
111
}
Magento\Customer\Controller\Account\ResetPasswordPost\$session
$session
Definition:
ResetPasswordPost.php:36
Magento\Customer\Controller\Account\ResetPasswordPost\$accountManagement
$accountManagement
Definition:
ResetPasswordPost.php:26
Magento\Customer\Controller\Account\ResetPasswordPost\$customerRepository
$customerRepository
Definition:
ResetPasswordPost.php:31
Magento\Customer\Model\Session
Definition:
Storage.php:8
__
__()
Definition:
__.php:13
Magento\Customer\Controller\Account\ResetPasswordPost
Definition:
ResetPasswordPost.php:21
Magento\Framework\App\Action\AbstractAction\getRequest
getRequest()
Definition:
AbstractAction.php:60
Magento\Framework\Exception\InputException
Definition:
InputException.php:17
Magento\Framework\App\ActionInterface\execute
execute()
Magento\Customer\Model\Session
Definition:
Session.php:22
Magento\Customer\Controller\Account\ResetPasswordPost\__construct
__construct(Context $context, Session $customerSession, AccountManagementInterface $accountManagement, CustomerRepositoryInterface $customerRepository, CredentialsValidator $credentialsValidator=null)
Definition:
ResetPasswordPost.php:47
Magento\Customer\Api\CustomerRepositoryInterface
Definition:
CustomerRepositoryInterface.php:15
Magento\Framework\App\Action\HttpPostActionInterface
Definition:
HttpPostActionInterface.php:16
Magento\Customer\Controller\Account
Definition:
Confirm.php:7
Magento\Framework\App\Action\Context
Definition:
Context.php:24
Magento\Customer\Model\Customer\CredentialsValidator
Definition:
CredentialsValidator.php:15
Magento\Customer\Api\AccountManagementInterface
Definition:
AccountManagementInterface.php:17
Magento\Customer\Controller\AbstractAccount
Definition:
AbstractAccount.php:16