148 end |
148 end |
149 |
149 |
150 -- retreive credentials |
150 -- retreive credentials |
151 local stored_key, server_key, salt, iteration_count; |
151 local stored_key, server_key, salt, iteration_count; |
152 if self.profile.plain then |
152 if self.profile.plain then |
153 local password, state = self.profile.plain(self, username, self.realm) |
153 local password, status = self.profile.plain(self, username, self.realm) |
154 if state == nil then return "failure", "not-authorized" |
154 if status == nil then return "failure", "not-authorized" |
155 elseif state == false then return "failure", "account-disabled" end |
155 elseif status == false then return "failure", "account-disabled" end |
156 |
156 |
157 password = saslprep(password); |
157 password = saslprep(password); |
158 if not password then |
158 if not password then |
159 log("debug", "Password violates SASLprep."); |
159 log("debug", "Password violates SASLprep."); |
160 return "failure", "not-authorized", "Invalid password." |
160 return "failure", "not-authorized", "Invalid password." |
168 if not succ then |
168 if not succ then |
169 log("error", "Generating authentication database failed. Reason: %s", stored_key); |
169 log("error", "Generating authentication database failed. Reason: %s", stored_key); |
170 return "failure", "temporary-auth-failure"; |
170 return "failure", "temporary-auth-failure"; |
171 end |
171 end |
172 elseif self.profile[profile_name] then |
172 elseif self.profile[profile_name] then |
173 local state; |
173 local status; |
174 stored_key, server_key, iteration_count, salt, state = self.profile[profile_name](self, username, self.realm); |
174 stored_key, server_key, iteration_count, salt, status = self.profile[profile_name](self, username, self.realm); |
175 if state == nil then return "failure", "not-authorized" |
175 if state == nil then return "failure", "not-authorized" |
176 elseif state == false then return "failure", "account-disabled" end |
176 elseif state == false then return "failure", "account-disabled" end |
177 end |
177 end |
178 |
178 |
179 local nonce = clientnonce .. generate_uuid(); |
179 local nonce = clientnonce .. generate_uuid(); |