1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
4 module("luci.controller.admin.index", package.seeall)
7 function toplevel_page(page, preflookup, preftarget)
8 if preflookup and preftarget then
9 if lookup(preflookup) then
10 page.target = preftarget
14 if not page.target then
15 page.target = firstchild()
20 if not root.target then
21 root.target = alias("admin")
25 local page = node("admin")
26 page.title = _("Administration")
29 page.sysauth_authenticator = "htmlauth"
32 toplevel_page(page, "admin/status/overview", alias("admin", "status"))
34 -- Empty menu tree to be populated by addons and modules
36 page = node("admin", "status")
37 page.title = _("Status")
40 -- overview is from mod-admin-full
41 toplevel_page(page, "admin/status/overview", alias("admin", "status", "overview"))
43 page = node("admin", "system")
44 page.title = _("System")
47 -- system/system is from mod-admin-full
48 toplevel_page(page, "admin/system/system", alias("admin", "system", "system"))
50 -- Only used if applications add items
51 page = node("admin", "services")
52 page.title = _("Services")
55 toplevel_page(page, false, false)
57 -- Even for mod-admin-full network just uses first submenu item as landing
58 page = node("admin", "network")
59 page.title = _("Network")
62 toplevel_page(page, false, false)
65 entry({"admin", "logout"}, call("action_logout"), _("Logout"), 999)
68 function action_logout()
69 local dsp = require "luci.dispatcher"
70 local utl = require "luci.util"
71 local sid = dsp.context.authsession
74 utl.ubus("session", "destroy", { ubus_rpc_session = sid })
76 luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s/" %{
77 sid, 'Thu, 01 Jan 1970 01:00:00 GMT', dsp.build_url()
81 luci.http.redirect(dsp.build_url())