modules/rpc: adapt rpc controller to sauth api changes

This commit is contained in:
Jo-Philipp Wich 2012-08-08 09:48:53 +00:00
parent 7bca24db1b
commit c8ffc897e3

View file

@ -27,9 +27,8 @@ function index()
if auth then -- if authentication token was given if auth then -- if authentication token was given
local sdat = luci.sauth.read(auth) local sdat = luci.sauth.read(auth)
if sdat then -- if given token is valid if sdat then -- if given token is valid
user = luci.sauth.decode(sdat).user if sdat.user and luci.util.contains(accs, sdat.user) then
if user and luci.util.contains(accs, user) then return sdat.user, auth
return user, auth
end end
end end
end end
@ -68,11 +67,12 @@ function rpc_auth()
secret = sys.uniqueid(16) secret = sys.uniqueid(16)
http.header("Set-Cookie", "sysauth=" .. sid.."; path=/") http.header("Set-Cookie", "sysauth=" .. sid.."; path=/")
sauth.write(sid, sauth.encode({ sauth.reap()
sauth.write(sid, {
user=user, user=user,
token=token, token=token,
secret=secret secret=secret
})) })
end end
return sid and {sid=sid, token=token, secret=secret} return sid and {sid=sid, token=token, secret=secret}