Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access denied for admin users in the custom module magento

I have created a custom module in magento for admin users, i have ready with a basic set up, i have created a user role and give resource access permission for this module, but when i login with that user credentials i am getting an access denied error, but when i login as admin i can access the module. My config.xml file

<?xml version="1.0"?>
<config>
    <global>
    <modules>
        <Su_VirtualRetailer>
            <version>0.1.0</version>    
        </Su_VirtualRetailer>
    </modules>
    <blocks>
            <virtualretailer>
                <rewrite>
         <virtualretailer>Su_VirtualRetailer_Block_VirtualRetailer</virtualretailer>
        </rewrite>
            </virtualretailer>
     </blocks>
     <helpers>
            <su_virtualretailer>
                <!-- Helper definition needed by Magento -->
                <class>Mage_Core_Helper</class>
            </su_virtualretailer>            
        </helpers>
    </global>
    <frontend>
        <routers>
            <virtualretailer>
                <use>standard</use>
                <args>
                    <module>Su_VirtualRetailer</module>
                    <frontName>virtualretailer</frontName>
                </args>
            </virtualretailer>
        </routers>
        <layout>
            <updates>
                <virtualretailer>
                      <file>virtualretailer.xml</file>
                </virtualretailer>
            </updates>
        </layout>
    </frontend>
   <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <su_virtualretailer before="Mage_Adminhtml">Su_VirtualRetailer_Adminhtml</su_virtualretailer>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

</config>

My adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <menu>
        <retailertab module="su_virtualretailer" translate="title">
            <title>Virtual Retailer</title>
            <sort_order>100</sort_order>
            <children>
                <index module="su_virtualretailer" translate="title">
                    <title>Home</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/custom</action>
                </index>
                <myaccount module="su_virtualretailer" translate="title">
                    <title>My Account</title>
                    <sort_order>2</sort_order>
                    <action>adminhtml/custom/list</action>
                </myaccount>
                <shop module="su_virtualretailer" translate="title">
                    <title>Shop</title>
                    <sort_order>3</sort_order>
                    <action>adminhtml/custom/shop</action>
                </shop>
            </children>
        </retailertab>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <retailertab translate="title" module="su_virtualretailer">
                        <title>Virtual Retailer</title>
                        <sort_order>-100</sort_order>
                        <children>
                            <index translate="title">
                                <title>Home Action</title>
                                <sort_order>1</sort_order>
                            </index>
                            <myaccount translate="title">
                                <title>My Account Action</title>
                                <sort_order>2</sort_order>
                            </myaccount>
                            <shop translate="title">
                                <title>Shop Action</title>
                                <sort_order>3</sort_order>
                            </shop>
                        </children>
                    </retailertab>
                </children>
            </admin>
        </resources>
    </acl>
</config>

i have given acl permissions in config.xml, i am not sure any thing that i did wrong here. admin user login error screen shot enter image description here

working for admin login, screen shot enter image description here

like image 788
Naveenbos Avatar asked Sep 16 '15 13:09

Naveenbos


2 Answers

Finally i got the answer, in the config.xml file i gave the below code

<acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>

            </resources>
</acl>

and in my controller file i gave below code

protected function _isAllowed(){
        return true;
    }

then everything working as expected

like image 90
Naveenbos Avatar answered Oct 23 '22 08:10

Naveenbos


Issue in your adminhtml.xml file

<config>
    <menu>
        <retailertab module="su_virtualretailer" translate="title">
            <title>Virtual Retailer</title>
            <sort_order>100</sort_order>
            <children>
                <index module="su_virtualretailer" translate="title">
                    <title>Home</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/custom</action>
                </index>
                <myaccount module="su_virtualretailer" translate="title">
                    <title>My Account</title>
                    <sort_order>2</sort_order>
                    <action>adminhtml/custom/list</action>
                </myaccount>
                <shop module="su_virtualretailer" translate="title">
                    <title>Shop</title>
                    <sort_order>3</sort_order>
                    <action>adminhtml/custom/shop</action>
                </shop>
            </children>
        </retailertab>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <retailertab translate="title" module="su_virtualretailer">
                        <title>Virtual Retailer</title>
                        <sort_order>-100</sort_order>
                        <children>
                            <index translate="title">
                                <title>Home Action</title>
                                <sort_order>1</sort_order>
                            </index>
                            <myaccount translate="title">
                                <title>My Account Action</title>
                                <sort_order>2</sort_order>
                            </myaccount>
                            <shop translate="title">
                                <title>Shop Action</title>
                                <sort_order>3</sort_order>
                            </shop>
                        </children>
                    </retailertab>
                </children>
            </admin>
        </resources>
    </acl>
</config>

Update code as per above.

just change your acl tree node custom to retailertab

like image 2
Chirag Nandaniya Avatar answered Oct 23 '22 08:10

Chirag Nandaniya