util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
--- a/util/prosodyctl.lua Tue Jun 29 19:11:18 2010 +0100
+++ b/util/prosodyctl.lua Tue Jun 29 19:18:07 2010 +0100
@@ -21,6 +21,8 @@
local CFG_SOURCEDIR = _G.CFG_SOURCEDIR;
+local prosody = prosody;
+
module "prosodyctl"
function adduser(params)
@@ -30,6 +32,11 @@
elseif not host then
return false, "invalid-hostname";
end
+
+ local provider = prosody.hosts[host].users;
+ if not(provider) or provider.name == "null" then
+ usermanager.initialize_host(host);
+ end
local ok = usermanager.create_user(user, password, host);
if not ok then
@@ -39,6 +46,11 @@
end
function user_exists(params)
+ local provider = prosody.hosts[host].users;
+ if not(provider) or provider.name == "null" then
+ usermanager.initialize_host(host);
+ end
+
return usermanager.user_exists(params.user, params.host);
end