ntopng/scripts/lua/rest/v2/get/demo/config.lua
GabrieleDeri d64863098b
Some checks are pending
Build / build (push) Waiting to run
CIFuzz / Fuzzing (address) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
CodeQL / Analyze-1 (push) Waiting to run
Reverted keepalive issue on logout, guided demo logic (#10688)
* Reverted keepalive issue on logout, guided demo logic

* Update dist
2026-08-04 14:24:01 +02:00

41 lines
1,008 B
Lua

--
-- (C) 2013-26 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
local rest_utils = require "rest_utils"
local demo_utils = require "demo_utils"
--
-- Get the full step config for a demo tour, plus the current user's saved progress
-- Example: curl -u admin:admin "http://localhost:3000/lua/rest/v2/get/demo/config.lua?id=ntopng_overview"
--
local res = {}
local demo_id = _GET["id"]
local username = _SESSION and _SESSION["user"]
if isEmptyString(demo_id) then
rest_utils.answer(rest_utils.consts.err.invalid_args, res)
return
end
if isEmptyString(username) then
rest_utils.answer(rest_utils.consts.err.not_granted, res)
return
end
local config = demo_utils.get_demo_config(demo_id)
if config == nil then
rest_utils.answer(rest_utils.consts.err.not_found, res)
return
end
res.config = config
res.progress = demo_utils.get_progress(username, demo_id)
rest_utils.answer(rest_utils.consts.success.ok, res)