Rework authentication system
[project/luci.git] / modules / rpc / luasrc / controller / rpc.lua
index 6b09116..b989b59 100644 (file)
@@ -27,7 +27,7 @@ function index()
                if auth then -- if authentication token was given
                        local sdat = luci.sauth.read(auth)
                        if sdat then -- if given token is valid
-                               user = loadstring(sdat)().user
+                               user = luci.sauth.decode(sdat).user
                                if user and luci.util.contains(accs, user) then
                                        return user, auth
                                end
@@ -68,7 +68,7 @@ function rpc_auth()
                        secret = sys.uniqueid(16)
 
                        http.header("Set-Cookie", "sysauth=" .. sid.."; path=/")
-                       sauth.write(sid, util.get_bytecode({
+                       sauth.write(sid, sauth.encode({
                                user=user,
                                token=token,
                                secret=secret