File

util/sasl/external.lua @ 13373:c724b097ce90

lua-format: Check in defaults By starting with the built-in defaults, we get a nice history of differences from those as we figure out what settings suit us Sorted make comparisons easier.
author Kim Alvefur <zash@zash.se>
date Tue, 07 Jul 2020 18:30:15 +0200
parent 12975:d10957394a3c
line wrap: on
line source

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

local _ENV = nil;
-- luacheck: std none

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

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

return {
	init = init;
}