Delete user sessions after password change

This commit is contained in:
Luca Deri 2023-08-25 12:39:17 +02:00
parent 947026e842
commit 66f720787a
2 changed files with 16 additions and 5 deletions

View file

@ -38,6 +38,16 @@ end
if(ntop.resetUserPassword(_SESSION["user"], username, old_password, new_password)) then
print ("{ \"result\" : 0, \"message\" : \"Password changed successfully\" }")
-- Delete sessions for the current user
local keys = ntop.getKeysCache("sessions.*")
for k,_ in pairs(keys) do
local v = ntop.getCache(k)
if(string.starts(v, username)) then
ntop.delCache(k)
end
end
else
print ("{ \"result\" : -1, \"message\" : \"Unable to set the new user password: perhaps the old password was invalid ?\" }")
end