9
9
10
10
use Magento \Customer \Api \AccountManagementInterface ;
11
11
use Magento \Customer \Model \ForgotPasswordToken \ConfirmCustomerByToken ;
12
+ use Magento \Customer \Model \ForgotPasswordToken \GetCustomerByToken ;
12
13
use Magento \Customer \Model \Session ;
13
14
use Magento \Framework \App \Action \HttpGetActionInterface ;
14
15
use Magento \Framework \View \Result \PageFactory ;
@@ -42,6 +43,11 @@ class CreatePassword extends \Magento\Customer\Controller\AbstractAccount implem
42
43
*/
43
44
private $ confirmByToken ;
44
45
46
+ /**
47
+ * @var \Magento\Customer\Model\ForgotPasswordToken\GetCustomerByToken
48
+ */
49
+ private $ getByToken ;
50
+
45
51
/**
46
52
* @param \Magento\Framework\App\Action\Context $context
47
53
* @param \Magento\Customer\Model\Session $customerSession
@@ -54,13 +60,16 @@ public function __construct(
54
60
Session $ customerSession ,
55
61
PageFactory $ resultPageFactory ,
56
62
AccountManagementInterface $ accountManagement ,
57
- ConfirmCustomerByToken $ confirmByToken = null
63
+ ConfirmCustomerByToken $ confirmByToken = null ,
64
+ GetCustomerByToken $ getByToken = null
58
65
) {
59
66
$ this ->session = $ customerSession ;
60
67
$ this ->resultPageFactory = $ resultPageFactory ;
61
68
$ this ->accountManagement = $ accountManagement ;
62
69
$ this ->confirmByToken = $ confirmByToken
63
70
?? ObjectManager::getInstance ()->get (ConfirmCustomerByToken::class);
71
+ $ this ->getByToken = $ getByToken
72
+ ?? ObjectManager::getInstance ()->get (GetCustomerByToken::class);
64
73
65
74
parent ::__construct ($ context );
66
75
}
@@ -83,6 +92,15 @@ public function execute()
83
92
84
93
$ this ->confirmByToken ->execute ($ resetPasswordToken );
85
94
95
+ try {
96
+ // Extend token validity to avoid expiration while this form is
97
+ // being completed by the user.
98
+ $ customer = $ this ->getByToken ->execute ($ resetPasswordToken );
99
+ $ this ->accountManagement ->changeResetPasswordLinkToken ($ customer , $ resetPasswordToken );
100
+ } catch (\Exception $ exception ) {
101
+ // Intentionally ignoring failures here
102
+ }
103
+
86
104
if ($ isDirectLink ) {
87
105
$ this ->session ->setRpToken ($ resetPasswordToken );
88
106
$ resultRedirect = $ this ->resultRedirectFactory ->create ();
0 commit comments