core/usermanager.lua

Thu, 30 Oct 2008 21:19:26 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 30 Oct 2008 21:19:26 +0000
changeset 187
2e16e5077d8f
parent 60
44800be871f5
child 228
875842235836
permissions
-rw-r--r--

Was a bit hasty to remove send_s2s() from stanza_router. We still use it, and there is no problem with it.


require "util.datamanager"
local datamanager = datamanager;
local log = require "util.logger".init("usermanager");

module "usermanager"

function validate_credentials(host, username, password)
	log("debug", "User '%s' is being validated", username);
	local credentials = datamanager.load(username, host, "accounts") or {};
	if password == credentials.password then return true; end
	return false;
end

function user_exists(username, host)
	return datamanager.load(username, host, "accounts") ~= nil;
end

function create_user(username, password, host)
	return datamanager.store(username, host, "accounts", {password = password});
end

return _M;

mercurial