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>
This commit is contained in:
parent
5dddb105d2
commit
425a02734e
1 changed files with 2 additions and 0 deletions
|
@ -417,6 +417,7 @@ function dispatch(request)
|
||||||
context.path = {}
|
context.path = {}
|
||||||
|
|
||||||
http.status(403, "Forbidden")
|
http.status(403, "Forbidden")
|
||||||
|
http.header("X-LuCI-Login-Required", "yes")
|
||||||
tmpl.render(track.sysauth_template or "sysauth", {
|
tmpl.render(track.sysauth_template or "sysauth", {
|
||||||
duser = default_user,
|
duser = default_user,
|
||||||
fuser = user
|
fuser = user
|
||||||
|
@ -433,6 +434,7 @@ function dispatch(request)
|
||||||
|
|
||||||
if not sid or not sdat then
|
if not sid or not sdat then
|
||||||
http.status(403, "Forbidden")
|
http.status(403, "Forbidden")
|
||||||
|
http.header("X-LuCI-Login-Required", "yes")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue