Changeset

4973:3f7248ac1a3b

mod_admin_telnet: Add some user management commands.
author Kim Alvefur <zash@zash.se>
date Mon, 09 Jul 2012 20:21:47 +0200
parents 4952:0e9a5b63206a
children 4974:1574f18b0ca4
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Mon Jul 09 02:35:47 2012 +0100
+++ b/plugins/mod_admin_telnet.lua	Mon Jul 09 20:21:47 2012 +0200
@@ -856,6 +856,37 @@
 	return setmetatable({ room = room_obj }, console_room_mt);
 end
 
+def_env.user = {};
+function def_env.user:create(jid, password)
+	local username, host = jid_split(jid);
+	local ok, err = um.create_user(username, password, host);
+	if ok then
+		return true, "User created";
+	else
+		return nil, "Could not create user: "..err;
+	end
+end
+
+function def_env.user:delete(jid)
+	local username, host = jid_split(jid);
+	local ok, err = um.delete_user(username, host);
+	if ok then
+		return true, "User deleted";
+	else
+		return nil, "Could not delete user: "..err;
+	end
+end
+
+function def_env.user:passwd(jid, password)
+	local username, host = jid_split(jid);
+	local ok, err = um.set_password(username, password, host);
+	if ok then
+		return true, "User created";
+	else
+		return nil, "Could not change password for user: "..err;
+	end
+end
+
 -------------
 
 function printbanner(session)