Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Auth.php
Go to the documentation of this file.
1 <?php
8 
12 use Magento\User\Model\UserFactory;
14 
18 abstract class Auth extends AbstractAction
19 {
25  protected $_userFactory;
26 
33  public function __construct(
34  Context $context,
35  UserFactory $userFactory
36  ) {
37  parent::__construct($context);
38  $this->_userFactory = $userFactory;
39  }
40 
49  protected function _validateResetPasswordLinkToken($userId, $resetPasswordToken)
50  {
51  if (!is_int(
52  $userId
53  ) || !is_string(
54  $resetPasswordToken
55  ) || empty($resetPasswordToken) || empty($userId) || $userId < 0
56  ) {
57  throw new LocalizedException(__('Please correct the password reset token.'));
58  }
59 
61  $user = $this->_userFactory->create()->load($userId);
62  if (!$user->getId()) {
63  throw new LocalizedException(
64  __('Please specify the correct account and try again.')
65  );
66  }
67 
68  $userToken = $user->getRpToken();
69  if (!Security::compareStrings($userToken, $resetPasswordToken) || $user->isResetPasswordLinkTokenExpired()) {
70  throw new LocalizedException(__('Your password reset link has expired.'));
71  }
72  }
73 
79  protected function _isAllowed()
80  {
81  return true;
82  }
83 }
__()
Definition: __.php:13
$user
Definition: dummy_user.php:13
__construct(Context $context, UserFactory $userFactory)
Definition: Auth.php:33
static compareStrings($expected, $actual)
Definition: Security.php:26