Software /
code /
prosody
Changeset
5042:ce823b32225e
usermanager: Add method for deleting a user
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 28 Jul 2012 21:55:05 +0200 |
parents | 5041:be204204cc5f |
children | 5043:2856e1cfbe95 |
files | core/usermanager.lua |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/core/usermanager.lua Sat Jul 28 21:38:22 2012 +0200 +++ b/core/usermanager.lua Sat Jul 28 21:55:05 2012 +0200 @@ -10,11 +10,13 @@ local log = require "util.logger".init("usermanager"); local type = type; local ipairs = ipairs; +local pairs = pairs; local jid_bare = require "util.jid".bare; local jid_prep = require "util.jid".prep; local config = require "core.configmanager"; local hosts = hosts; local sasl_new = require "util.sasl".new; +local storagemanager = require "core.storagemanager"; local prosody = _G.prosody; @@ -88,7 +90,15 @@ end function delete_user(username, host) - return hosts[host].users.delete_user(username); + local user = hosts[host].sessions[username]; + if user and user.sessions then + for jid, session in pairs(user.sessions) do + session:close{ condition = "not-authorized", text = "Account deleted" }; + end + end + local ok, err = hosts[host].users.delete_user(username); + if not ok then return nil, err; end + return storagemanager.get_driver(host):purge(username); end function get_sasl_handler(host, session)