Software /
code /
prosody
Changeset
5598:3bb8aefd8ce0
mod_admin_telnet: Verify that the host exists in user commands (Thanks SkyBlue)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 18 May 2013 13:19:31 +0200 |
parents | 5597:6fe09707c73b |
children | 5599:34e9f237b915 5621:63cfd59999b6 |
files | plugins/mod_admin_telnet.lua |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua Sat May 18 13:14:19 2013 +0200 +++ b/plugins/mod_admin_telnet.lua Sat May 18 13:19:31 2013 +0200 @@ -939,7 +939,9 @@ def_env.user = {}; function def_env.user:create(jid, password) local username, host = jid_split(jid); - if um.user_exists(username, host) then + if not hosts[host] then + return nil, "No such host: "..host; + elseif um.user_exists(username, host) then return nil, "User exists"; end local ok, err = um.create_user(username, password, host); @@ -952,7 +954,9 @@ function def_env.user:delete(jid) local username, host = jid_split(jid); - if not um.user_exists(username, host) then + if not hosts[host] then + return nil, "No such host: "..host; + elseif um.user_exists(username, host) then return nil, "No such user"; end local ok, err = um.delete_user(username, host); @@ -965,7 +969,9 @@ function def_env.user:password(jid, password) local username, host = jid_split(jid); - if not um.user_exists(username, host) then + if not hosts[host] then + return nil, "No such host: "..host; + elseif um.user_exists(username, host) then return nil, "No such user"; end local ok, err = um.set_password(username, password, host);