Access denied for admin users in the custom module magento
Asked Answered
A

2

6

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

Automobile answered 16/9, 2015 at 13:8 Comment(2)
I think Admin has to give the permission to another user from "Role Resource" under the System > Permissions > Roles.Cue
I have given that permissions but not workingAutomobile
A
16

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

Automobile answered 17/9, 2015 at 7:3 Comment(2)
Most modules have the allowed everything under all. The _isAllowed function is the one that's missing. Upvoted!Attica
@Automobile Perfect answer. Thanks !Heterozygous
R
2

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

Raybin answered 16/9, 2015 at 18:27 Comment(2)
I have changed this as you said Chirag, but the same error is getting, access denied.Automobile
Don't know why but somehow this is not working in my case as well.Xanthine

© 2022 - 2024 — McMap. All rights reserved.