Auth.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * MageSpecialist
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to info@magespecialist.it so we can send you a copy immediately.
  14. *
  15. * @category MSP
  16. * @package MSP_TwoFactorAuth
  17. * @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. namespace MSP\TwoFactorAuth\Block\Provider\U2fKey;
  21. use Magento\Backend\Block\Template;
  22. use Magento\Backend\Model\Auth\Session;
  23. use MSP\TwoFactorAuth\Model\Provider\Engine\U2fKey;
  24. class Auth extends Template
  25. {
  26. /**
  27. * @var U2fKey
  28. */
  29. private $u2fKey;
  30. /**
  31. * @var Session
  32. */
  33. private $session;
  34. public function __construct(
  35. Template\Context $context,
  36. Session $session,
  37. U2fKey $u2fKey,
  38. array $data = []
  39. ) {
  40. parent::__construct($context, $data);
  41. $this->u2fKey = $u2fKey;
  42. $this->session = $session;
  43. }
  44. /**
  45. * @inheritdoc
  46. */
  47. public function getJsLayout()
  48. {
  49. $this->jsLayout['components']['msp-twofactorauth-auth']['postUrl'] =
  50. $this->getUrl('*/*/authpost');
  51. $this->jsLayout['components']['msp-twofactorauth-auth']['successUrl'] =
  52. $this->getUrl($this->_urlBuilder->getStartupPageUrl());
  53. $this->jsLayout['components']['msp-twofactorauth-auth']['touchImageUrl'] =
  54. $this->getViewFileUrl('MSP_TwoFactorAuth::images/u2f/touch.png');
  55. $this->jsLayout['components']['msp-twofactorauth-auth']['authenticateData'] =
  56. $this->u2fKey->getAuthenticateData($this->session->getUser());
  57. return parent::getJsLayout();
  58. }
  59. }