Diff

util/prosodyctl.lua @ 3294:89dd67cc3689

util.prosodyctl: Initialize the host's auth provider if necessary (thanks johnny, and all the other people whom this hindered :) )
author Matthew Wild <mwild1@gmail.com>
date Tue, 29 Jun 2010 19:18:07 +0100
parent 2925:692b3c6c5bd2
child 3307:3d7acda82eed
line wrap: on
line diff
--- 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