16
16
use Magento \Framework \App \Config \Storage \WriterInterface ;
17
17
use Magento \Framework \App \Config \ScopeConfigInterface ;
18
18
use Magento \Framework \Encryption \EncryptorInterface ;
19
+ use Magento \Framework \Exception \LocalizedException ;
19
20
use Magento \Framework \UrlInterface ;
20
21
21
22
class ImsConfig extends Config
@@ -30,7 +31,6 @@ class ImsConfig extends Config
30
31
public const XML_PATH_VALIDATE_TOKEN_URL = 'adobe_ims/integration/validate_token_url ' ;
31
32
public const XML_PATH_LOGOUT_URL = 'adobe_ims/integration/logout_url ' ;
32
33
public const XML_PATH_CERTIFICATE_PATH = 'adobe_ims/integration/certificate_path ' ;
33
- public const XML_PATH_ADOBE_IMS_2FA_ENABLED = 'adobe_ims/integration/adobe_ims_2fa_enabled ' ;
34
34
public const XML_PATH_ADMIN_AUTH_URL_PATTERN = 'adobe_ims/integration/admin/auth_url_pattern ' ;
35
35
public const XML_PATH_ADMIN_REAUTH_URL_PATTERN = 'adobe_ims/integration/admin/reauth_url_pattern ' ;
36
36
public const XML_PATH_ADMIN_ADOBE_IMS_SCOPES = 'adobe_ims/integration/admin/scopes ' ;
@@ -110,13 +110,20 @@ public function loggingEnabled(): bool
110
110
* @param string $organizationId
111
111
* @param bool $isAdobeIms2FAEnabled
112
112
* @return void
113
+ * @throws LocalizedException
113
114
*/
114
115
public function enableModule (
115
116
string $ clientId ,
116
117
string $ clientSecret ,
117
118
string $ organizationId ,
118
119
bool $ isAdobeIms2FAEnabled
119
120
): void {
121
+ if (!$ isAdobeIms2FAEnabled ) {
122
+ throw new LocalizedException (
123
+ __ ('2FA Auth is required when enabling the Admin Adobe IMS Module ' )
124
+ );
125
+ }
126
+
120
127
$ this ->updateConfig (
121
128
self ::XML_PATH_ENABLED ,
122
129
'1 '
@@ -136,11 +143,6 @@ public function enableModule(
136
143
self ::XML_PATH_PRIVATE_KEY ,
137
144
$ clientSecret
138
145
);
139
-
140
- $ this ->updateConfig (
141
- self ::XML_PATH_ADOBE_IMS_2FA_ENABLED ,
142
- (string ) $ isAdobeIms2FAEnabled
143
- );
144
146
}
145
147
146
148
/**
@@ -158,7 +160,6 @@ public function disableModule(): void
158
160
$ this ->deleteConfig (self ::XML_PATH_ORGANIZATION_ID );
159
161
$ this ->deleteConfig (self ::XML_PATH_API_KEY );
160
162
$ this ->deleteConfig (self ::XML_PATH_PRIVATE_KEY );
161
- $ this ->deleteConfig (self ::XML_PATH_ADOBE_IMS_2FA_ENABLED );
162
163
}
163
164
164
165
/**
@@ -198,7 +199,7 @@ public function getValidateTokenUrl(string $code, string $tokenType): string
198
199
* @param string $value
199
200
* @return void
200
201
*/
201
- public function updateConfig (string $ path , string $ value ): void
202
+ private function updateConfig (string $ path , string $ value ): void
202
203
{
203
204
$ this ->writer ->save (
204
205
$ path ,
@@ -213,7 +214,7 @@ public function updateConfig(string $path, string $value): void
213
214
* @param string $value
214
215
* @return void
215
216
*/
216
- public function updateSecureConfig (string $ path , string $ value ): void
217
+ private function updateSecureConfig (string $ path , string $ value ): void
217
218
{
218
219
$ value = str_replace (['\n ' , '\r ' ], ["\n" , "\r" ], $ value );
219
220
@@ -233,7 +234,7 @@ public function updateSecureConfig(string $path, string $value): void
233
234
* @param string $path
234
235
* @return void
235
236
*/
236
- public function deleteConfig (string $ path ): void
237
+ private function deleteConfig (string $ path ): void
237
238
{
238
239
$ this ->writer ->delete ($ path );
239
240
}
@@ -286,7 +287,7 @@ public function getAdminAdobeImsReAuthUrl(): string
286
287
*
287
288
* @return string
288
289
*/
289
- public function getScopes (): string
290
+ private function getScopes (): string
290
291
{
291
292
return implode (
292
293
', ' ,
0 commit comments