X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fdispatcher.lua;h=0bd19456f2d583d1b7846bde3df6d1c01d1862a2;hp=cd5d77a12b9237134d66be1e1d6174d03efdd01a;hb=57121f37432fdc4e3eb5f577b4c3fdcb622932ee;hpb=e19098d0623e96690e65539b36c59965ae1373d5 diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua index cd5d77a12..0bd19456f 100644 --- a/modules/luci-base/luasrc/dispatcher.lua +++ b/modules/luci-base/luasrc/dispatcher.lua @@ -101,7 +101,7 @@ function error500(message) return false end -function authenticator.htmlauth(validator, accs, default) +function authenticator.htmlauth(validator, accs, default, template) local user = http.formvalue("luci_username") local pass = http.formvalue("luci_password") @@ -113,7 +113,7 @@ function authenticator.htmlauth(validator, accs, default) require("luci.template") context.path = {} http.status(403, "Forbidden") - luci.template.render("sysauth", {duser=default, fuser=user}) + luci.template.render(template or "sysauth", {duser=default, fuser=user}) return false @@ -197,6 +197,7 @@ function dispatch(request) assert(conf.main, "/etc/config/luci seems to be corrupt, unable to find section 'main'") + local i18n = require "luci.i18n" local lang = conf.main.lang or "auto" if lang == "auto" then local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or "" @@ -208,7 +209,10 @@ function dispatch(request) end end end - require "luci.i18n".setlanguage(lang) + if lang == "auto" then + lang = i18n.default + end + i18n.setlanguage(lang) local c = ctx.tree local stat @@ -273,6 +277,13 @@ function dispatch(request) if cond then local env = getfenv(3) local scope = (type(env.self) == "table") and env.self + if type(val) == "table" then + if not next(val) then + return '' + else + val = util.serialize_json(val) + end + end return string.format( ' %s="%s"', tostring(key), util.pcdata(tostring( val @@ -317,7 +328,7 @@ function dispatch(request) "Access Violation\nThe page at '" .. table.concat(request, "/") .. "/' " .. "has no parent node so the access to this location has been denied.\n" .. "This is a software bug, please report this message at " .. - "http://luci.subsignal.org/trac/newticket" + "https://github.com/openwrt/luci/issues" ) if track.sysauth then @@ -349,7 +360,7 @@ function dispatch(request) if not util.contains(accs, user) then if authen then - local user, sess = authen(sys.user.checkpasswd, accs, def) + local user, sess = authen(sys.user.checkpasswd, accs, def, track.sysauth_template) local token if not user or not util.contains(accs, user) then return @@ -402,9 +413,6 @@ function dispatch(request) end if track.setuser then - -- trigger ubus connection before dropping root privs - util.ubus() - sys.process.setuser(track.setuser) end