util.pubsub: Small code tidying for :get_subscription()
[prosody.git] / util / prosodyctl.lua
index f6cb8d7ffd2e598e276b2de29c0bd9daf77a22fd..40d21be86b617ac8a82230b88561720c28c96e10 100644 (file)
@@ -10,6 +10,7 @@
 local config = require "core.configmanager";
 local encodings = require "util.encodings";
 local stringprep = encodings.stringprep;
+local storagemanager = require "core.storagemanager";
 local usermanager = require "core.usermanager";
 local signal = require "util.signal";
 local set = require "util.set";
@@ -38,21 +39,24 @@ function adduser(params)
        if not(provider) or provider.name == "null" then
                usermanager.initialize_host(host);
        end
+       storagemanager.initialize_host(host);
        
-       local ok = usermanager.create_user(user, password, host);
+       local ok, errmsg = usermanager.create_user(user, password, host);
        if not ok then
-               return false, "unable-to-save-data";
+               return false, errmsg;
        end
        return true;
 end
 
 function user_exists(params)
-       local provider = prosody.hosts[params.host].users;
+       local user, host, password = nodeprep(params.user), nameprep(params.host), params.password;
+       local provider = prosody.hosts[host].users;
        if not(provider) or provider.name == "null" then
-               usermanager.initialize_host(params.host);
+               usermanager.initialize_host(host);
        end
+       storagemanager.initialize_host(host);
        
-       return usermanager.user_exists(params.user, params.host);
+       return usermanager.user_exists(user, host);
 end
 
 function passwd(params)