+--- Render and evaluate the system authentication login form.
+-- @param default Default username
+-- @return Authentication status
+function sysauth(default)
+ local user = luci.http.formvalue("username")
+ local pass = luci.http.formvalue("password")
+
+ if user and luci.sys.user.checkpasswd(user, pass) then
+ local sid = luci.sys.uniqueid(16)
+ luci.http.header("Set-Cookie", "sysauth=" .. sid.."; path=/")
+ luci.sauth.write(sid, user)
+ return true
+ else
+ require("luci.i18n")
+ require("luci.template")
+ context.path = {}
+ luci.template.render("sysauth", {duser=default, fuser=user})
+ return false
+ end
+end
+
+--- Dispatch an HTTP request.
+-- @param request LuCI HTTP Request object