plugins/mod_saslauth.lua

changeset 1073
7c20373d4451
parent 1072
c7967004b5d0
child 1186
078eb3b109e9
equal deleted inserted replaced
1072:c7967004b5d0 1073:7c20373d4451
39 if err_msg then reply:tag("text"):text(err_msg); end 39 if err_msg then reply:tag("text"):text(err_msg); end
40 elseif status == "success" then 40 elseif status == "success" then
41 log("debug", "%s", ret or ""); 41 log("debug", "%s", ret or "");
42 reply:text(base64.encode(ret or "")); 42 reply:text(base64.encode(ret or ""));
43 else 43 else
44 error("Unknown sasl status: "..status); 44 module:log("error", "Unknown sasl status: %s", status);
45 end 45 end
46 return reply; 46 return reply;
47 end 47 end
48 48
49 local function handle_status(session, status) 49 local function handle_status(session, status)
50 if status == "failure" then 50 if status == "failure" then
51 session.sasl_handler = nil; 51 session.sasl_handler = nil;
52 elseif status == "success" then 52 elseif status == "success" then
53 if not session.sasl_handler.username then error("SASL succeeded but we didn't get a username!"); end -- TODO move this to sessionmanager 53 if not session.sasl_handler.username then -- TODO move this to sessionmanager
54 module:log("warn", "SASL succeeded but we didn't get a username!");
55 session.sasl_handler = nil;
56 session:reset_stream();
57 return;
58 end
54 sm_make_authenticated(session, session.sasl_handler.username); 59 sm_make_authenticated(session, session.sasl_handler.username);
55 session.sasl_handler = nil; 60 session.sasl_handler = nil;
56 session:reset_stream(); 61 session:reset_stream();
57 end 62 end
58 end 63 end

mercurial