|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +declare(strict_types=1); |
| 8 | + |
7 | 9 | namespace Magento\User\Model\ResourceModel;
|
8 | 10 |
|
9 | 11 | use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
|
@@ -208,27 +210,23 @@ protected function _createUserRole($parentId, ModelUser $user)
|
208 | 210 | if ($parentId > 0) {
|
209 | 211 | /** @var \Magento\Authorization\Model\Role $parentRole */
|
210 | 212 | $parentRole = $this->_roleFactory->create()->load($parentId);
|
211 |
| - } else { |
212 |
| - $role = new \Magento\Framework\DataObject(); |
213 |
| - $role->setTreeLevel(0); |
214 |
| - } |
215 |
| - |
216 |
| - if ($parentRole->getId()) { |
217 |
| - $data = new \Magento\Framework\DataObject( |
218 |
| - [ |
219 |
| - 'parent_id' => $parentRole->getId(), |
220 |
| - 'tree_level' => $parentRole->getTreeLevel() + 1, |
221 |
| - 'sort_order' => 0, |
222 |
| - 'role_type' => RoleUser::ROLE_TYPE, |
223 |
| - 'user_id' => $user->getId(), |
224 |
| - 'user_type' => UserContextInterface::USER_TYPE_ADMIN, |
225 |
| - 'role_name' => $user->getFirstName(), |
226 |
| - ] |
227 |
| - ); |
228 |
| - |
229 |
| - $insertData = $this->_prepareDataForTable($data, $this->getTable('authorization_role')); |
230 |
| - $this->getConnection()->insert($this->getTable('authorization_role'), $insertData); |
231 |
| - $this->aclDataCache->clean(); |
| 213 | + if ($parentRole->getId()) { |
| 214 | + $data = new \Magento\Framework\DataObject( |
| 215 | + [ |
| 216 | + 'parent_id' => $parentRole->getId(), |
| 217 | + 'tree_level' => $parentRole->getTreeLevel() + 1, |
| 218 | + 'sort_order' => 0, |
| 219 | + 'role_type' => RoleUser::ROLE_TYPE, |
| 220 | + 'user_id' => $user->getId(), |
| 221 | + 'user_type' => UserContextInterface::USER_TYPE_ADMIN, |
| 222 | + 'role_name' => $user->getFirstName(), |
| 223 | + ] |
| 224 | + ); |
| 225 | + |
| 226 | + $insertData = $this->_prepareDataForTable($data, $this->getTable('authorization_role')); |
| 227 | + $this->getConnection()->insert($this->getTable('authorization_role'), $insertData); |
| 228 | + $this->aclDataCache->clean(); |
| 229 | + } |
232 | 230 | }
|
233 | 231 | }
|
234 | 232 |
|
@@ -267,8 +265,6 @@ public function delete(\Magento\Framework\Model\AbstractModel $user)
|
267 | 265 | ['user_id = ?' => $uid, 'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN]
|
268 | 266 | );
|
269 | 267 | } catch (\Magento\Framework\Exception\LocalizedException $e) {
|
270 |
| - throw $e; |
271 |
| - } catch (\Exception $e) { |
272 | 268 | $connection->rollBack();
|
273 | 269 | return false;
|
274 | 270 | }
|
@@ -476,7 +472,7 @@ public function updateRoleUsersAcl(\Magento\Authorization\Model\Role $role)
|
476 | 472 | $users = $role->getRoleUsers();
|
477 | 473 | $rowsCount = 0;
|
478 | 474 |
|
479 |
| - if (sizeof($users) > 0) { |
| 475 | + if (count($users) > 0) { |
480 | 476 | $bind = ['reload_acl_flag' => 1];
|
481 | 477 | $where = ['user_id IN(?)' => $users];
|
482 | 478 | $rowsCount = $connection->update($this->getTable('admin_user'), $bind, $where);
|
@@ -618,6 +614,7 @@ public function trackPassword($user, $passwordHash, $lifetime = 0)
|
618 | 614 |
|
619 | 615 | /**
|
620 | 616 | * Get latest password for specified user id
|
| 617 | + * |
621 | 618 | * Possible false positive when password was changed several times with different lifetime configuration
|
622 | 619 | *
|
623 | 620 | * @param int $userId
|
|
0 commit comments