X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fdispatcher.lua;h=16b32548e6f626b2928cb6b2589e26947494085d;hp=1b684aa79c93271fca9a0f02511451d6af212d88;hb=a441721d32d06d18368bf236ad127ffccad0bef8;hpb=314dd1aa11d1fbe3501928e89823e2521eb651d3 diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua index 1b684aa79..16b32548e 100644 --- a/modules/luci-base/luasrc/dispatcher.lua +++ b/modules/luci-base/luasrc/dispatcher.lua @@ -191,6 +191,9 @@ local function session_setup(user, pass, allowed_users) timeout = tonumber(luci.config.sauth.sessiontime) }) + local rp = context.requestpath + and table.concat(context.requestpath, "/") or "" + if type(login) == "table" and type(login.ubus_rpc_session) == "string" then @@ -199,8 +202,14 @@ local function session_setup(user, pass, allowed_users) values = { token = sys.uniqueid(16) } }) + io.stderr:write("luci: accepted login on /%s for %s from %s\n" + %{ rp, user, http.getenv("REMOTE_ADDR") or "?" }) + return session_retrieve(login.ubus_rpc_session) end + + io.stderr:write("luci: failed login on /%s for %s from %s\n" + %{ rp, user, http.getenv("REMOTE_ADDR") or "?" }) end return nil, nil @@ -219,10 +228,19 @@ function dispatch(request) local lang = conf.main.lang or "auto" if lang == "auto" then local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or "" - for lpat in aclang:gmatch("[%w-]+") do - lpat = lpat and lpat:gsub("-", "_") - if conf.languages[lpat] then - lang = lpat + for aclang in aclang:gmatch("[%w_-]+") do + local country, culture = aclang:match("^([a-z][a-z])[_-]([a-zA-Z][a-zA-Z])$") + if country and culture then + local cc = "%s_%s" %{ country, culture:lower() } + if conf.languages[cc] then + lang = cc + break + elseif conf.languages[country] then + lang = country + break + end + elseif conf.languages[aclang] then + lang = aclang break end end @@ -349,7 +367,7 @@ function dispatch(request) "https://github.com/openwrt/luci/issues" ) - if track.sysauth then + if track.sysauth and not ctx.authsession then local authen = track.sysauth_authenticator local _, sid, sdat, default_user, allowed_users