1

I created a user, and I can't add any role to him..enter image description here

I want to add this roles to my user... my code is below... and when I save the user and the role, I don't see this green "V" on my role.. I just see that my user and role was attached and the role is empty..

 $roleAuthModel = $objectManager->create('\Magento\Authorization\Model\Role');

            $roleAuthModel->setName($this->userName)
            ->setPid("0")
            ->setRoleType("G")
            ->setUserType(UserContextInterface::USER_TYPE_ADMIN);
            $roleAuthModel->save();

            $resource = [
                'Magento_Backend::admin',
                'Magento_Products::inventory',
                'Magento_Products::inventory_catalog',
                'Magento_Products::inventory_categories'
            ];

            $roleAuthModel->setRoleId($roleAuthModel->getId())->setResources($resource)->save();

            $userModel->setRoleId($roleAuthModel->getId());
  • Any help ? Thanks... – MEIR May 16 '17 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.