X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fsasl%2Fplain.lua;h=c9ec2911797ecaacae50ac0e6f969adb062b5591;hb=ecd2e6962f8993af96ffa869659f7949e64054ae;hp=fb20cf97d45e0424afd7c7044c5062dc37d68b73;hpb=093e7bb084c42c8ec56cc94bbd51cff25f94664a;p=prosody.git diff --git a/util/sasl/plain.lua b/util/sasl/plain.lua index fb20cf97..c9ec2911 100644 --- a/util/sasl/plain.lua +++ b/util/sasl/plain.lua @@ -13,6 +13,7 @@ local s_match = string.match; local saslprep = require "util.encodings".stringprep.saslprep; +local nodeprep = require "util.encodings".stringprep.nodeprep; local log = require "util.logger".init("sasl"); module "sasl.plain" @@ -54,6 +55,14 @@ local function plain(self, message) return "failure", "malformed-request", "Invalid username or password."; end + local _nodeprep = self.profile.nodeprep; + if _nodeprep ~= false then + authentication = (_nodeprep or nodeprep)(authentication); + if not authentication or authentication == "" then + return "failure", "malformed-request", "Invalid username or password." + end + end + local correct, state = false, false; if self.profile.plain then local correct_password; @@ -64,15 +73,13 @@ local function plain(self, message) end self.username = authentication - if not state then + if state == false then return "failure", "account-disabled"; - end - - if correct then - return "success"; - else + elseif state == nil or not correct then return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent."; end + + return "success"; end function init(registerMechanism)