@@ -17,12 +17,12 @@ class AdminAccount
17
17
/**#@+
18
18
* Data keys
19
19
*/
20
- const KEY_USER = 'admin-user ' ;
21
- const KEY_PASSWORD = 'admin-password ' ;
22
- const KEY_EMAIL = 'admin-email ' ;
23
- const KEY_FIRST_NAME = 'admin-firstname ' ;
24
- const KEY_LAST_NAME = 'admin-lastname ' ;
25
- const KEY_PREFIX = 'db-prefix ' ;
20
+ public const KEY_USER = 'admin-user ' ;
21
+ public const KEY_PASSWORD = 'admin-password ' ;
22
+ public const KEY_EMAIL = 'admin-email ' ;
23
+ public const KEY_FIRST_NAME = 'admin-firstname ' ;
24
+ public const KEY_LAST_NAME = 'admin-lastname ' ;
25
+ public const KEY_PREFIX = 'db-prefix ' ;
26
26
/**#@- */
27
27
28
28
/**
@@ -154,8 +154,7 @@ private function trackPassword($adminId, $passwordHash)
154
154
}
155
155
156
156
/**
157
- * Validates that the username and email both match the user,
158
- * and that password exists and is different from user name.
157
+ * Validate that the username and email both match the user,and that password exists and is different from username.
159
158
*
160
159
* @return void
161
160
* @throws \Exception If the username and email do not both match data provided to install
@@ -164,12 +163,14 @@ private function trackPassword($adminId, $passwordHash)
164
163
public function validateUserMatches ()
165
164
{
166
165
if (empty ($ this ->data [self ::KEY_PASSWORD ])) {
166
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
167
167
throw new \Exception (
168
168
'"Password" is required. Enter and try again. '
169
169
);
170
170
}
171
171
172
172
if (strcasecmp ($ this ->data [self ::KEY_PASSWORD ], $ this ->data [self ::KEY_USER ]) == 0 ) {
173
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
173
174
throw new \Exception (
174
175
'Password cannot be the same as the user name. '
175
176
);
@@ -191,6 +192,7 @@ public function validateUserMatches()
191
192
if ((strcasecmp ($ email , $ this ->data [self ::KEY_EMAIL ]) == 0 ) &&
192
193
(strcasecmp ($ username , $ this ->data [self ::KEY_USER ]) != 0 )) {
193
194
// email matched but username did not
195
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
194
196
throw new \Exception (
195
197
'An existing user has the given email but different username. '
196
198
. 'Username and email both need to match an existing user or both be new. '
@@ -199,6 +201,7 @@ public function validateUserMatches()
199
201
if ((strcasecmp ($ username , $ this ->data [self ::KEY_USER ]) == 0 ) &&
200
202
(strcasecmp ($ email , $ this ->data [self ::KEY_EMAIL ]) != 0 )) {
201
203
// username matched but email did not
204
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
202
205
throw new \Exception (
203
206
'An existing user has the given username but different email. '
204
207
. 'Username and email both need to match an existing user or both be new. '
@@ -258,6 +261,7 @@ private function retrieveAdministratorsRoleId()
258
261
$ administratorsRoleData
259
262
);
260
263
if (empty ($ result )) {
264
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
261
265
throw new \Exception ('No administrators role was found, data fixture needs to be run ' );
262
266
} else {
263
267
// Found at least one, use first
0 commit comments