9d6a38ed4373cbc3711f145d42907c9f3e8b621f
[project/luci.git] / modules / admin-mini / luasrc / controller / mini / index.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15
16 module("luci.controller.mini.index", package.seeall)
17
18 function index()
19         local root = node()
20         if not root.lock then
21                 root.target = alias("mini")
22                 root.index = true
23         end
24         
25         entry({"about"}, template("about"))
26         
27         local page   = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10)
28         page.sysauth = "root"
29         page.sysauth_authenticator = "htmlauth"
30         page.index = true
31         
32         entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true
33         entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true
34         entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10)
35         entry({"mini", "index", "logout"}, call("action_logout"), _("Logout"))
36 end
37
38 function action_logout()
39         local dsp = require "luci.dispatcher"
40         local sauth = require "luci.sauth"
41         if dsp.context.authsession then
42                 sauth.kill(dsp.context.authsession)
43                 dsp.context.urltoken.stok = nil
44         end
45
46         luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
47         luci.http.redirect(luci.dispatcher.build_url())
48 end