mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Initial import from SVN
This commit is contained in:
parent
1601f6bbf2
commit
730d76b9f5
1612 changed files with 715104 additions and 0 deletions
38
scripts/lua/admin/password_reset.lua
Normal file
38
scripts/lua/admin/password_reset.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--
|
||||
-- (C) 2013 - ntop.org
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
require "lua_utils"
|
||||
|
||||
sendHTTPHeader('text/html; charset=iso-8859-1')
|
||||
|
||||
username = _GET["username"]
|
||||
old_password = _GET["old_password"]
|
||||
new_password = _GET["new_password"]
|
||||
confirm_new_password = _GET["confirm_new_password"]
|
||||
|
||||
user_group = ntop.getUserGroup()
|
||||
if(user_group == "administrator") then
|
||||
old_password = ""
|
||||
else
|
||||
-- Check to avoid that this user changes password for other users
|
||||
username = _COOKIE["user"]
|
||||
end
|
||||
|
||||
if((username == nil) or (old_password == nil) or (new_password == nil) or (confirm_new_password == nil)) then
|
||||
print ("{ \"result\" : -1, \"message\" : \"Invalid parameters\" }")
|
||||
return
|
||||
end
|
||||
|
||||
if(new_password ~= confirm_new_password) then
|
||||
print ("{ \"result\" : -1, \"message\" : \"Password don't match\" }")
|
||||
return
|
||||
end
|
||||
|
||||
if(ntop.resetUserPassword(_SESSION["user"], username, old_password, new_password)) then
|
||||
print ("{ \"result\" : 0, \"message\" : \"Password changed successfully\" }")
|
||||
else
|
||||
print ("{ \"result\" : -1, \"message\" : \"Unable to set the new user password: perhaps the old password was invalid ?\" }")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue