TfaSession.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\Model;
  21. use Magento\Framework\Session\SessionManager;
  22. use MSP\TwoFactorAuth\Api\TfaSessionInterface;
  23. class TfaSession extends SessionManager implements TfaSessionInterface
  24. {
  25. /**
  26. * Set 2FA session as passed
  27. * @return $this
  28. */
  29. public function grantAccess()
  30. {
  31. $this->storage->setData(TfaSessionInterface::KEY_PASSED, true);
  32. return $this;
  33. }
  34. /**
  35. * Return true if 2FA session has been passed
  36. * @return boolean
  37. */
  38. public function isGranted()
  39. {
  40. return !!$this->storage->getData(TfaSessionInterface::KEY_PASSED);
  41. }
  42. }