Diff

plugins/mod_saslauth.lua @ 3240:9782a222e941

Merge 0.7->trunk
author Matthew Wild <mwild1@gmail.com>
date Sat, 12 Jun 2010 02:39:18 +0100
parent 3188:c690e3c5105c
parent 3238:362b94fa5a30
child 3350:f0e312c9da01
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Fri Jun 11 20:45:00 2010 +0500
+++ b/plugins/mod_saslauth.lua	Sat Jun 12 02:39:18 2010 +0100
@@ -95,17 +95,17 @@
 		session.sasl_handler = session.sasl_handler:clean_clone();
 	elseif status == "success" then
 		local username = nodeprep(session.sasl_handler.username);
-		if not username then -- TODO move this to sessionmanager
-			module:log("warn", "SASL succeeded but we didn't get a username!");
-			session.sasl_handler = nil;
-			session:reset_stream();
-			return status, ret, err_msg;
-		end
 
 		if not(require_provisioning) or usermanager_user_exists(username, session.host) then
-			sm_make_authenticated(session, session.sasl_handler.username);
-			session.sasl_handler = nil;
-			session:reset_stream();
+			local aret, err = sm_make_authenticated(session, session.sasl_handler.username);
+			if aret then
+				session.sasl_handler = nil;
+				session:reset_stream();
+			else
+				module:log("warn", "SASL succeeded but username was invalid");
+				session.sasl_handler = session.sasl_handler:clean_clone();
+				return "failure", "not-authorized", "User authenticated successfully, but username was invalid";
+			end
 		else
 			module:log("warn", "SASL succeeded but we don't have an account provisioned for %s", username);
 			session.sasl_handler = session.sasl_handler:clean_clone();