1919use Magento \TwoFactorAuth \Api \UserConfigRequestManagerInterface ;
2020use Magento \TwoFactorAuth \Controller \Adminhtml \AbstractAction ;
2121use Magento \TwoFactorAuth \Model \UserConfig \HtmlAreaTokenVerifier ;
22- use Magento \TwoFactorAuth \Model \TfaSession ;
23- use Magento \Framework \App \ObjectManager ;
24- use Magento \TwoFactorAuth \Model \Exception \NotificationException ;
2522
2623/**
2724 * Request 2FA config from the user.
@@ -33,6 +30,8 @@ class Requestconfig extends AbstractAction implements HttpGetActionInterface, Ht
3330 */
3431 public const ADMIN_RESOURCE = 'Magento_TwoFactorAuth::tfa ' ;
3532
33+ private const TFA_EMAIL_SENT = 'tfa_email_sent ' ;
34+
3635 /**
3736 * @var UserConfigRequestManagerInterface
3837 */
@@ -53,33 +52,25 @@ class Requestconfig extends AbstractAction implements HttpGetActionInterface, Ht
5352 */
5453 private $ session ;
5554
56- /**
57- * @var TfaSession
58- */
59- private $ tfaSession ;
60-
6155 /**
6256 * @param Context $context
6357 * @param UserConfigRequestManagerInterface $configRequestManager
6458 * @param HtmlAreaTokenVerifier $tokenVerifier
6559 * @param TfaInterface $tfa
6660 * @param Session $session
67- * @param TfaSession $tfaSession
6861 */
6962 public function __construct (
7063 Context $ context ,
7164 UserConfigRequestManagerInterface $ configRequestManager ,
7265 HtmlAreaTokenVerifier $ tokenVerifier ,
7366 TfaInterface $ tfa ,
74- Session $ session ,
75- TfaSession $ tfaSession
67+ Session $ session
7668 ) {
7769 parent ::__construct ($ context );
7870 $ this ->configRequestManager = $ configRequestManager ;
7971 $ this ->tokenVerifier = $ tokenVerifier ;
8072 $ this ->tfa = $ tfa ;
8173 $ this ->session = $ session ;
82- $ this ->tfaSession = $ tfaSession ?? ObjectManager::getInstance ()->get (TfaSession::class);
8374 }
8475
8576 /**
@@ -100,11 +91,10 @@ public function execute()
10091 }
10192
10293 try {
103- if ($ this ->tfaSession ->isTfaEmailSent ()) {
104- throw new NotificationException ();
94+ if (!$ this ->session ->getData (self ::TFA_EMAIL_SENT )) {
95+ $ this ->configRequestManager ->sendConfigRequestTo ($ user );
96+ $ this ->session ->setData (self ::TFA_EMAIL_SENT , true );
10597 }
106- $ this ->configRequestManager ->sendConfigRequestTo ($ user );
107- $ this ->tfaSession ->setTfaEmailSentFlag ();
10898 } catch (AuthorizationException $ exception ) {
10999 $ this ->messageManager ->addErrorMessage (
110100 'Please ask an administrator with sufficient access to configure 2FA first '
0 commit comments