Added ability to set historical flow permission to users (#6330)

This commit is contained in:
MatteoBiscosi 2022-04-07 12:41:28 +02:00
parent 297b5d4edb
commit 61f74ce0a1
16 changed files with 454 additions and 290 deletions

View file

@ -13,6 +13,7 @@ local host_role = _POST["user_role"]
local networks = _POST["allowed_networks"]
local allowed_interface = _POST["allowed_interface"]
local allow_pcap_download = _POST["allow_pcap_download"]
local allow_historical_flow = _POST["allow_historical_flow"]
local language = _POST["user_language"]
-- for captive portal users
@ -64,6 +65,15 @@ if(not ntop.changeUserPermission(username, allow_pcap_download_enabled)) then
return
end
local allow_historical_flow_enabled = false
if allow_historical_flow and allow_historical_flow == "1" then
allow_historical_flow_enabled = true;
end
if(not ntop.changeHistoricalFlowPermission(username, allow_historical_flow_enabled)) then
print ("{ \"result\" : -1, \"message\" : \"Error in changing user historical flow permission\" }")
return
end
if(language ~= nil) then
if(not ntop.changeUserLanguage(username, language)) then
print ("{ \"result\" : -1, \"message\" : \"Error in changing the user language\" }")

View file

@ -44,12 +44,18 @@ if(isAdministratorOrPrintErr()) then
value["language"] = locales_utils.default_locale
end
end
print(' "language": "'..value["language"]..'",\n')
if value["allow_pcap_download"] then
print(' "allow_pcap_download": true,\n')
end
print(' "language": "'..value["language"]..'",\n')
if value["allow_pcap_download"] then
print(' "allow_pcap_download": true,\n')
end
local api_token = ntop.getUserAPIToken(key) or ""
print(' "language": "'..value["language"]..'",\n')
if value["allow_historical_flow"] then
print(' "allow_historical_flow": true,\n')
end
local api_token = ntop.getUserAPIToken(key) or ""
print(' "username": "'..key..'",\n')
print(' "api_token": "' ..api_token.. '",\n')

View file

@ -1,5 +1,5 @@
--
-- (C) 2013 - ntop.org
-- (C) 2022 - ntop.org
--
dirs = ntop.getDirs()