ntopng/scripts/lua/admin/validate_new_user.lua
Matteo Biscosi bbd3502a8c Reworked some settings pages.
Also fixed some security bugs, linting and permissions checks
2026-10-23 21:46:18 +02:00

22 lines
687 B
Lua

--
-- (C) 2013 - ntop.org
--
dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
sendHTTPHeader('application/json')
if(isAdministratorOrPrintErr()) then
local json = require "dkjson"
local username = string.lower(_GET["username"] or "")
local existing = ntop.getCache("ntopng.user.".. username ..".password")
-- Same answer as before, encoded (the username is user input)
if(string.len(existing) > 0) then
print(json.encode({ valid = 0, user = username, msg = "User already existing" }) .. "\n")
else
print(json.encode({ valid = 1, user = username, msg = "Ok" }) .. "\n")
end
end