util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
authorMatthew Wild <mwild1@gmail.com>
Tue, 29 Jun 2010 19:18:07 +0100
changeset 3294 89dd67cc3689
parent 3293 4ce9d569a99c
child 3301 772fb30b28fb
util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
util/prosodyctl.lua
--- 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