1

I have created a admin user by below command.

php bin/magento admin:user:create --admin-user="admin1" --admin-password="admin@123" --admin-email="admin1@gmail.com" --admin-firstname="fname" --admin-lastname="lname"

Now, Admin is login successfully but I do not have permission for anything in admin. Below is the Error.

Sorry, you need permissions to view this content. Please help me how can I solve this.

1

Check your module's acl.xml file for error & then do setup upgrade. If issue still persists then comment code in acl.xml file & then do setup upgrade. Hope this will help!

1

this issue is related to admin created user access. it is occurs if user try to access unauthorised resources i suggest you to do the following two things

1) check your acl.xml file and provide access to the resource from backend using administrator credencials navigate to system>>user roles>>resources and checked the recource option

2) remove/comment the _isAllowed() method body from controller file. like below.

protected function _isAllowed()
{
    return $this->_authorization->isAllowed('Vendor_ModuleName::Resource');
}
0

There are some other things that you can have to do to have access again.

As far as I know, if you do not have access to the back-office, you will not be able to change permission for the new user.

In that case, you will need to do plain sql modifications as explained in this post : Reset roles for Magento 2

If you have access with another user to the back-office, go to Magento documentation about admin users and follow instructions for the user with restricted access. It will unlock the permission for the other user.

2
  • Thanks @Christophe I have try with your suggested URL(Reset roles for Magento 2) but it's not working for me. Dec 13 '18 at 8:56
  • Can you please provide me with the queries you've made ? Update your question for more clarity. Dec 13 '18 at 9:39
0

If you have recently done your Magento setup and facing this issue,

Clear all the cache and generated folder. Please let me know if this works, thank you!

rm -rf var/* generated/*
0

There is no code to check if the 2FA is enabled or not. In Magento2.4.2 it is allowed by default. To correct this I have done some changes and these are working for me.

  1. Magento\TwoFactorAuth\Observer\ControllerActionPredispatch.php

Add below code in execute() method

public function execute(Observer $observer)
       {

           if (!$this->tfa->isEnabled()) {
               return;
           }
  1. Magento\TwoFactorAuth\Model\Tfa.php

change

public function isEnabled(): bool
   {
       return true;
   }


   to

  
public function isEnabled(): bool
   {
       return !!$this->scopeConfig->getValue(TfaInterface::XML_PATH_ENABLED);
   }
  1. Added in file vendor\magento\module-two-factor-auth\Api\TfaInterface.php

const XML_PATH_ENABLED = 'twofactorauth/general/enabled';

After these changes, if you disable the 2FA then it will bypass this

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.