+ uci.leaf = true
+
+ uci = entry({"rpc", "auth"}, call("rpc_auth"))
+end
+
+function rpc_auth()
+ require "luci.jsonrpc"
+ require "luci.sauth"
+
+ luci.http.setfilehandler()
+
+ local loginstat
+
+ local server = {}
+ server.login = function(user, pass)
+ local sid
+
+ if luci.sys.user.checkpasswd(user, pass) then
+ sid = luci.sys.uniqueid(16)
+ luci.http.header("Set-Cookie", "sysauth=" .. sid.."; path=/")
+ luci.sauth.write(sid, user)
+ end
+
+ return sid
+ end
+
+ luci.http.prepare_content("application/json")
+ luci.http.write(luci.jsonrpc.handle(server, luci.http.content()))
+
+ return loginstat