luci-base: luci.dispatcher: allow overriding sysauth template
[project/luci.git] / modules / luci-base / luasrc / dispatcher.lua
index c7903e6..0bd1945 100644 (file)
@@ -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
@@ -356,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