Comparison

plugins/mod_admin_telnet.lua @ 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
parent 4913:02dbed57a355
child 4974:1574f18b0ca4
comparison
equal deleted inserted replaced
4952:0e9a5b63206a 4973:3f7248ac1a3b
854 return nil, "No such room: "..room_jid; 854 return nil, "No such room: "..room_jid;
855 end 855 end
856 return setmetatable({ room = room_obj }, console_room_mt); 856 return setmetatable({ room = room_obj }, console_room_mt);
857 end 857 end
858 858
859 def_env.user = {};
860 function def_env.user:create(jid, password)
861 local username, host = jid_split(jid);
862 local ok, err = um.create_user(username, password, host);
863 if ok then
864 return true, "User created";
865 else
866 return nil, "Could not create user: "..err;
867 end
868 end
869
870 function def_env.user:delete(jid)
871 local username, host = jid_split(jid);
872 local ok, err = um.delete_user(username, host);
873 if ok then
874 return true, "User deleted";
875 else
876 return nil, "Could not delete user: "..err;
877 end
878 end
879
880 function def_env.user:passwd(jid, password)
881 local username, host = jid_split(jid);
882 local ok, err = um.set_password(username, password, host);
883 if ok then
884 return true, "User created";
885 else
886 return nil, "Could not change password for user: "..err;
887 end
888 end
889
859 ------------- 890 -------------
860 891
861 function printbanner(session) 892 function printbanner(session)
862 local option = config.get("*", "core", "console_banner"); 893 local option = config.get("*", "core", "console_banner");
863 if option == nil or option == "full" or option == "graphic" then 894 if option == nil or option == "full" or option == "graphic" then