Comparison

plugins/mod_admin_adhoc.lua @ 5100:65207b768f60

mod_admin_adhoc: Use usermanager.delete_user to delete users
author Kim Alvefur <zash@zash.se>
date Sat, 25 Aug 2012 01:31:49 +0200
parent 5076:88fb94df9b18
child 5135:52eafe0e9772
comparison
equal deleted inserted replaced
5099:39eb688e106a 5100:65207b768f60
12 12
13 local iterators = require "util.iterators"; 13 local iterators = require "util.iterators";
14 local keys, values = iterators.keys, iterators.values; 14 local keys, values = iterators.keys, iterators.values;
15 local usermanager_user_exists = require "core.usermanager".user_exists; 15 local usermanager_user_exists = require "core.usermanager".user_exists;
16 local usermanager_create_user = require "core.usermanager".create_user; 16 local usermanager_create_user = require "core.usermanager".create_user;
17 local usermanager_delete_user = require "core.usermanager".delete_user;
17 local usermanager_get_password = require "core.usermanager".get_password; 18 local usermanager_get_password = require "core.usermanager".get_password;
18 local usermanager_set_password = require "core.usermanager".set_password; 19 local usermanager_set_password = require "core.usermanager".set_password;
19 local is_admin = require "core.usermanager".is_admin; 20 local is_admin = require "core.usermanager".is_admin;
20 local rm_load_roster = require "core.rostermanager".load_roster; 21 local rm_load_roster = require "core.rostermanager".load_roster;
21 local st, jid, uuid = require "util.stanza", require "util.jid", require "util.uuid"; 22 local st, jid, uuid = require "util.stanza", require "util.jid", require "util.uuid";
140 end 141 end
141 local failed = {}; 142 local failed = {};
142 local succeeded = {}; 143 local succeeded = {};
143 for _, aJID in ipairs(fields.accountjids) do 144 for _, aJID in ipairs(fields.accountjids) do
144 local username, host, resource = jid.split(aJID); 145 local username, host, resource = jid.split(aJID);
145 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) and usermanager_create_user(username, nil, host) then 146 if (host == data.to) and usermanager_user_exists(username, host) and usermanager_delete_user(username, host) then
146 module:log("debug", "User %s has been deleted", aJID); 147 module:log("debug", "User %s has been deleted", aJID);
147 succeeded[#succeeded+1] = aJID; 148 succeeded[#succeeded+1] = aJID;
148 else 149 else
149 module:log("debug", "Tried to delete non-existant user %s", aJID); 150 module:log("debug", "Tried to delete non-existant user %s", aJID);
150 failed[#failed+1] = aJID; 151 failed[#failed+1] = aJID;