19
19
use Magento \TwoFactorAuth \Api \UserConfigRequestManagerInterface ;
20
20
use Magento \TwoFactorAuth \Controller \Adminhtml \AbstractAction ;
21
21
use Magento \TwoFactorAuth \Model \UserConfig \HtmlAreaTokenVerifier ;
22
- use Magento \TwoFactorAuth \Model \TfaSession ;
23
- use Magento \Framework \App \ObjectManager ;
24
- use Magento \TwoFactorAuth \Model \Exception \NotificationException ;
25
22
26
23
/**
27
24
* Request 2FA config from the user.
@@ -33,6 +30,8 @@ class Requestconfig extends AbstractAction implements HttpGetActionInterface, Ht
33
30
*/
34
31
public const ADMIN_RESOURCE = 'Magento_TwoFactorAuth::tfa ' ;
35
32
33
+ private const TFA_EMAIL_SENT = 'tfa_email_sent ' ;
34
+
36
35
/**
37
36
* @var UserConfigRequestManagerInterface
38
37
*/
@@ -53,33 +52,25 @@ class Requestconfig extends AbstractAction implements HttpGetActionInterface, Ht
53
52
*/
54
53
private $ session ;
55
54
56
- /**
57
- * @var TfaSession
58
- */
59
- private $ tfaSession ;
60
-
61
55
/**
62
56
* @param Context $context
63
57
* @param UserConfigRequestManagerInterface $configRequestManager
64
58
* @param HtmlAreaTokenVerifier $tokenVerifier
65
59
* @param TfaInterface $tfa
66
60
* @param Session $session
67
- * @param TfaSession $tfaSession
68
61
*/
69
62
public function __construct (
70
63
Context $ context ,
71
64
UserConfigRequestManagerInterface $ configRequestManager ,
72
65
HtmlAreaTokenVerifier $ tokenVerifier ,
73
66
TfaInterface $ tfa ,
74
- Session $ session ,
75
- TfaSession $ tfaSession
67
+ Session $ session
76
68
) {
77
69
parent ::__construct ($ context );
78
70
$ this ->configRequestManager = $ configRequestManager ;
79
71
$ this ->tokenVerifier = $ tokenVerifier ;
80
72
$ this ->tfa = $ tfa ;
81
73
$ this ->session = $ session ;
82
- $ this ->tfaSession = $ tfaSession ?? ObjectManager::getInstance ()->get (TfaSession::class);
83
74
}
84
75
85
76
/**
@@ -100,11 +91,10 @@ public function execute()
100
91
}
101
92
102
93
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 );
105
97
}
106
- $ this ->configRequestManager ->sendConfigRequestTo ($ user );
107
- $ this ->tfaSession ->setTfaEmailSentFlag ();
108
98
} catch (AuthorizationException $ exception ) {
109
99
$ this ->messageManager ->addErrorMessage (
110
100
'Please ask an administrator with sufficient access to configure 2FA first '
0 commit comments