File

util/sasl/external.lua @ 6126:122e0f26e8f6

plugins/muc/muc.lib: Use `get_role` in `handle_admin_item_get_command`. Removed a TODO that's already done
author daurnimator <quae@daurnimator.com>
date Wed, 19 Mar 2014 17:46:25 -0400
parent 5687:e879b53e9df8
child 6777:5de6b93d0190
line wrap: on
line source

local saslprep = require "util.encodings".stringprep.saslprep;

module "sasl.external"

local function external(self, message)
	message = saslprep(message);
	local state
	self.username, state = self.profile.external(message);

	if state == false then
		return "failure", "account-disabled";
	elseif state == nil  then
		return "failure", "not-authorized";
	elseif state == "expired" then
		return "false", "credentials-expired";
	end

	return "success";
end

function init(registerMechanism)
	registerMechanism("EXTERNAL", {"external"}, external);
end

return _M;