index.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. dsp.context.urltoken.stok = nil
  29. luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s/" %{
  30. sid, 'Thu, 01 Jan 1970 01:00:00 GMT', dsp.build_url()
  31. })
  32. end
  33. luci.http.redirect(luci.dispatcher.build_url())
  34. end