aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_telnet.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-09-19 12:14:08 +0100
committerMatthew Wild <mwild1@gmail.com>2012-09-19 12:14:08 +0100
commita868b41b589356e9231df919a1771cc99b20d54b (patch)
treecf7a08a965f0bb9816285dcc830a140b62fc0ab1 /plugins/mod_admin_telnet.lua
parent8ffa6ad43baaab15a9bf11d51d229312315ac44e (diff)
parent3b96fac7491ce85877b7ee2038ae90b2d501ca6c (diff)
downloadprosody-a868b41b589356e9231df919a1771cc99b20d54b.tar.gz
prosody-a868b41b589356e9231df919a1771cc99b20d54b.zip
Merge 0.9->trunk
Diffstat (limited to 'plugins/mod_admin_telnet.lua')
-rw-r--r--plugins/mod_admin_telnet.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index bdd6e87e..62fb10a0 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -227,7 +227,7 @@ function commands.help(session, data)
elseif section == "user" then
print [[user:create(jid, password) - Create the specified user account]]
print [[user:password(jid, password) - Set the password for the specified user account]]
- print [[user:delete(jid, password) - Permanently remove the specified user account]]
+ print [[user:delete(jid) - Permanently remove the specified user account]]
elseif section == "server" then
print [[server:version() - Show the server's version number]]
print [[server:uptime() - Show how long the server has been running]]
@@ -915,6 +915,9 @@ local um = require"core.usermanager";
def_env.user = {};
function def_env.user:create(jid, password)
local username, host = jid_split(jid);
+ if um.user_exists(username, host) then
+ return nil, "User exists";
+ end
local ok, err = um.create_user(username, password, host);
if ok then
return true, "User created";
@@ -925,6 +928,9 @@ end
function def_env.user:delete(jid)
local username, host = jid_split(jid);
+ if not um.user_exists(username, host) then
+ return nil, "No such user";
+ end
local ok, err = um.delete_user(username, host);
if ok then
return true, "User deleted";
@@ -933,11 +939,14 @@ function def_env.user:delete(jid)
end
end
-function def_env.user:passwd(jid, password)
+function def_env.user:password(jid, password)
local username, host = jid_split(jid);
+ if not um.user_exists(username, host) then
+ return nil, "No such user";
+ end
local ok, err = um.set_password(username, password, host);
if ok then
- return true, "User created";
+ return true, "User password changed";
else
return nil, "Could not change password for user: "..err;
end