index.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. module("luci.controller.admin.index", package.seeall)
  4. function index()
  5. local root = node()
  6. if not root.target then
  7. root.target = alias("admin")
  8. root.index = true
  9. end
  10. local page = node("admin")
  11. page.target = firstchild()
  12. page.title = _("Administration")
  13. page.order = 10
  14. page.sysauth = "root"
  15. page.sysauth_authenticator = "htmlauth"
  16. page.ucidata = true
  17. page.index = true
  18. -- Empty services menu to be populated by addons
  19. entry({"admin", "services"}, firstchild(), _("Services"), 40).index = true
  20. entry({"admin", "logout"}, call("action_logout"), _("Logout"), 90)
  21. end
  22. function action_logout()
  23. local dsp = require "luci.dispatcher"
  24. local utl = require "luci.util"
  25. local sid = dsp.context.authsession
  26. if sid then
  27. utl.ubus("session", "destroy", { ubus_rpc_session = sid })
  28. luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s/" %{
  29. sid, 'Thu, 01 Jan 1970 01:00:00 GMT', dsp.build_url()
  30. })
  31. end
  32. luci.http.redirect(dsp.build_url())
  33. end