Data.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\User\Helper;
  7. /**
  8. * User data helper
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Data extends \Magento\Framework\App\Helper\AbstractHelper
  14. {
  15. /**
  16. * Configuration path to expiration period of reset password link
  17. */
  18. const XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD = 'admin/security/password_reset_link_expiration_period';
  19. /**
  20. * @var \Magento\Backend\App\ConfigInterface
  21. */
  22. protected $_config;
  23. /**
  24. * @var \Magento\Framework\Math\Random
  25. */
  26. protected $mathRandom;
  27. /**
  28. * @param \Magento\Framework\App\Helper\Context $context
  29. * @param \Magento\Backend\App\ConfigInterface $config
  30. * @param \Magento\Framework\Math\Random $mathRandom
  31. */
  32. public function __construct(
  33. \Magento\Framework\App\Helper\Context $context,
  34. \Magento\Backend\App\ConfigInterface $config,
  35. \Magento\Framework\Math\Random $mathRandom
  36. ) {
  37. $this->_config = $config;
  38. $this->mathRandom = $mathRandom;
  39. parent::__construct($context);
  40. }
  41. /**
  42. * Generate unique token for reset password confirmation link
  43. *
  44. * @return string
  45. */
  46. public function generateResetPasswordLinkToken()
  47. {
  48. return $this->mathRandom->getUniqueHash();
  49. }
  50. /**
  51. * Retrieve customer reset password link expiration period in days
  52. *
  53. * @return int
  54. */
  55. public function getResetPasswordLinkExpirationPeriod()
  56. {
  57. return (int)$this->_config->getValue(self::XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD);
  58. }
  59. }