dispatcher.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --- a/package/feeds/luci/luci-base/luasrc/dispatcher.lua
  2. +++ b/package/feeds/luci/luci-base/luasrc/dispatcher.lua
  3. @@ -461,5 +461,10 @@
  4. context.request = r
  5. - local pathinfo = http.urldecode(request:getenv("PATH_INFO") or "", true)
  6. + local pathinfo = ""
  7. + if sys.call("test -s /tmp/resolv.conf.d/resolv.conf.auto") == 0 then
  8. + pathinfo = http.urldecode(request:getenv("PATH_INFO") or "", true)
  9. + else
  10. + pathinfo = http.urldecode(request:getenv("PATH_INFO") or "admin/system/initsetup", true)
  11. + end
  12. if prefix then
  13. @@ -894,6 +899,11 @@
  14. end
  15. - http.header("Set-Cookie", 'sysauth=%s; path=%s; SameSite=Strict; HttpOnly%s' %{
  16. - sid, build_url(), http.getenv("HTTPS") == "on" and "; secure" or ""
  17. + local cookie_p = uci:get("wizard", "default", "cookie_p")
  18. + local timeout = 'Thu, 01 Jan 3000 01:00:00 GMT'
  19. + if cookie_p == '0' then
  20. + timeout = ''
  21. + end
  22. + http.header("Set-Cookie", 'sysauth=%s; expires=%s; path=%s; SameSite=Strict; HttpOnly%s' %{
  23. + sid, timeout, build_url(), http.getenv("HTTPS") == "on" and "; secure" or ""
  24. })
  25. @@ -917,6 +927,12 @@
  26. local perm = check_acl_depends(required_path_acls, ctx.authacl and ctx.authacl["access-group"])
  27. if perm == nil then
  28. - http.status(403, "Forbidden")
  29. - return
  30. + local sid = context.authsession
  31. + if sid then
  32. + util.ubus("session", "destroy", { ubus_rpc_session = sid })
  33. + luci.http.header("Set-Cookie", "sysauth=%s; expires=%s; path=%s" %{
  34. + '', 'Thu, 01 Jan 1970 01:00:00 GMT', build_url()
  35. + })
  36. + end
  37. + luci.http.redirect(build_url())
  38. end