index.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --[[
  2. LuCI - Lua Configuration Interface
  3. Copyright 2008 Steven Barth <steven@midlink.org>
  4. Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. $Id$
  10. ]]--
  11. module("luci.controller.admin.index", package.seeall)
  12. function index()
  13. local uci_state = luci.model.uci.cursor_state()
  14. local configmode = uci_state:get_first("gluon-config-mode", "wizard", "running", "0") == "1"
  15. local root = node()
  16. if not root.lock then
  17. root.target = alias("admin")
  18. root.index = true
  19. end
  20. local page = entry({"admin"}, alias("admin", "index"), _("Expertmode"), 10)
  21. page.sysauth = "root"
  22. if configmode then
  23. -- force root to be logged in when running in configmode
  24. page.sysauth_authenticator = function() return "root" end
  25. else
  26. page.sysauth_authenticator = "htmlauth"
  27. end
  28. page.index = true
  29. entry({"admin", "index"}, form("admin/index"), _("Overview"), 1).ignoreindex = true
  30. entry({"admin", "logout"}, call("action_logout"), _("Logout"))
  31. end
  32. function action_logout()
  33. local dsp = require "luci.dispatcher"
  34. local sauth = require "luci.sauth"
  35. if dsp.context.authsession then
  36. sauth.kill(dsp.context.authsession)
  37. dsp.context.urltoken.stok = nil
  38. end
  39. luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
  40. luci.http.redirect(luci.dispatcher.build_url())
  41. end