summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-11-16 19:33:39 +0100
committerJo-Philipp Wich <jo@mein.io>2018-11-16 21:11:34 +0100
commit425a02734e28ec41403511aa1c46cbe489930ff1 (patch)
treeec5b8cae02c75a7dc5f43dc877e848ad9a8a02bf /modules
parent5dddb105d2f7a96bf135154c7aceb6f830bc0463 (diff)
luci-base: dispatcher: add login indication on 403 errors
Send a custom LuCI X-Header to indicate that a login is required to access the requested resource. This is mainly intended for xhr.js to be able to intercept such responses and popup an authentication dialog. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/luasrc/dispatcher.lua2
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
index 1e610e748..c4066a259 100644
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ b/modules/luci-base/luasrc/dispatcher.lua
@@ -417,6 +417,7 @@ function dispatch(request)
context.path = {}
http.status(403, "Forbidden")
+ http.header("X-LuCI-Login-Required", "yes")
tmpl.render(track.sysauth_template or "sysauth", {
duser = default_user,
fuser = user
@@ -433,6 +434,7 @@ function dispatch(request)
if not sid or not sdat then
http.status(403, "Forbidden")
+ http.header("X-LuCI-Login-Required", "yes")
return
end