modules/admin-full: switch back to alias() for / -> /admin/; chained firstchild(...
[project/luci.git] / modules / admin-full / luasrc / controller / admin / index.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 module("luci.controller.admin.index", package.seeall)
16
17 function index()
18         local root = node()
19         if not root.target then
20                 root.target = alias("admin")
21                 root.index = true
22         end
23
24         local page   = node("admin")
25         page.target  = firstchild()
26         page.title   = _("Administration")
27         page.order   = 10
28         page.sysauth = "root"
29         page.sysauth_authenticator = "htmlauth"
30         page.ucidata = true
31         page.index = true
32
33         -- Empty services menu to be populated by addons
34         entry({"admin", "services"}, firstchild(), _("Services"), 40).index = true
35
36         entry({"admin", "logout"}, call("action_logout"), _("Logout"), 90)
37 end
38
39 function action_logout()
40         local dsp = require "luci.dispatcher"
41         local sauth = require "luci.sauth"
42         if dsp.context.authsession then
43                 sauth.kill(dsp.context.authsession)
44                 dsp.context.urltoken.stok = nil
45         end
46
47         luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
48         luci.http.redirect(luci.dispatcher.build_url())
49 end