How to hide Luci menu items before login

I added a custom module to Luci following the guide below.

Everything works fine. The only problem is the menu item I added is visible even when logged out. However when I click the menu the login prompt is shown as expected as the module is under the admin path. All other built-in menus like Status, System, Network, etc. stay hidden when logged-out. I would like my custom menu item also to be only visible when logged in.

I'd suggest you post your controller file to get a better quality reply.

It's same as the one in the link I posted. Here is using exact copy paste from that page. I only removed the comments.

Here is the result


As you can see the newly added menu item is visible before login. Other menus are hidden and will become visible only after login

I remember reading the document which described how to control visibility of nodes to non-logged users, but I've just tried to find it again and couldn't.

Have you checked all the other controller files for clues?

As I haven't installed any apps the only other controller present is the main admin controller, which has only two files 'index.lua' and 'uci.lua'. Those files do not have an index() function.

I noticed the same "problem" with myself. One dependency is missing from the menu. Sample menu fragment from my application.

function index()
	entry({"admin", "modem"}, firstchild(), "Modem", 30).dependent=false
	entry({"admin", "modem", "sms"}, alias("admin", "modem", "sms", "readsms"), translate("SMS Messages"), 20).acl_depends={ "luci-app-sms-tool" }

The key here is:

.acl_depends={ "luci-app-sms-tool" }

Adding dependencies

usr / share / rpcd / acl.d / luci-app-sms-tool.json

does the trick.

1 Like

Thanks. It worked.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.