index.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. module("luci.controller.mini.index", package.seeall)
  5. function index()
  6. local root = node()
  7. if not root.lock then
  8. root.target = alias("mini")
  9. root.index = true
  10. end
  11. entry({"about"}, template("about"))
  12. local page = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10)
  13. page.sysauth = "root"
  14. page.sysauth_authenticator = "htmlauth"
  15. page.index = true
  16. entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true
  17. entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true
  18. entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10)
  19. entry({"mini", "index", "logout"}, call("action_logout"), _("Logout"))
  20. end
  21. function action_logout()
  22. local dsp = require "luci.dispatcher"
  23. local utl = require "luci.util"
  24. if dsp.context.authsession then
  25. utl.ubus("session", "destroy", {
  26. ubus_rpc_session = dsp.context.authsession
  27. })
  28. dsp.context.urltoken.stok = nil
  29. end
  30. luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
  31. luci.http.redirect(luci.dispatcher.build_url())
  32. end