dd25f2c52bb305ce70c514dd107c57eb3cf5e2ba
[project/luci.git] / modules / luci-mod-admin-mini / luasrc / controller / mini / index.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 module("luci.controller.mini.index", package.seeall)
6
7 function index()
8         local root = node()
9         if not root.lock then
10                 root.target = alias("mini")
11                 root.index = true
12         end
13         
14         entry({"about"}, template("about"))
15         
16         local page   = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10)
17         page.sysauth = "root"
18         page.sysauth_authenticator = "htmlauth"
19         page.index = true
20         
21         entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true
22         entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true
23         entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10)
24         entry({"mini", "index", "logout"}, call("action_logout"), _("Logout"))
25 end
26
27 function action_logout()
28         local dsp = require "luci.dispatcher"
29         local utl = require "luci.util"
30         if dsp.context.authsession then
31                 utl.ubus("session", "destroy", {
32                         ubus_rpc_session = dsp.context.authsession
33                 })
34                 dsp.context.urltoken.stok = nil
35         end
36
37         luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
38         luci.http.redirect(luci.dispatcher.build_url())
39 end