1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

improve OS API

This commit is contained in:
lxsang 2021-02-09 01:30:08 +01:00
parent 83288a00b0
commit d135587c3b
2 changed files with 14 additions and 3 deletions

View File

@ -183,7 +183,9 @@ function SystemController:apigateway(...)
print("Web socket is not available.")
end
else
if REQUEST.json then
if REQUEST.path then
exec_with_user_priv(REQUEST)
elseif REQUEST.json then
data = JSON.decodeString(REQUEST.json)
--std.json()
exec_with_user_priv(data)

View File

@ -26,11 +26,20 @@ function sysdb()
end
function is_auth()
if SESSION.sessionid == nil or SESSION.sessionid == '0' then return false end
local sessionid = nil
if SESSION.sessionid and SESSION.sessionid ~= '0' then
sessionid = SESSION.sessionid
-- should be used only by API call
elseif REQUEST.sessionid and REQUEST.sessionid ~= '0' then
sessionid = REQUEST.sessionid
end
if sessionid == nil then
return false
end
-- query session id from database
local db = sysdb()
if db == nil then return false end
local cond = {exp= {["="] = { sessionid = SESSION.sessionid }}}
local cond = {exp= {["="] = { sessionid = sessionid }}}
local data = db:find(cond)
--print(JSON.encode(data))
db:close()