Comparison

plugins/mod_saslauth.lua @ 4504:55b61221ecb8

mod_saslauth: Move authentication-success event to after session has been made authenticated.
author Kim Alvefur <zash@zash.se>
date Sun, 12 Feb 2012 15:05:31 +0100
parent 4492:0a4781f165e3
child 4505:b1e10c327d66
comparison
equal deleted inserted replaced
4502:dd1eaecc11f9 4504:55b61221ecb8
49 local function handle_status(session, status, ret, err_msg) 49 local function handle_status(session, status, ret, err_msg)
50 if status == "failure" then 50 if status == "failure" then
51 module:fire_event("authentication-failure", { session = session, condition = ret, text = err_msg }); 51 module:fire_event("authentication-failure", { session = session, condition = ret, text = err_msg });
52 session.sasl_handler = session.sasl_handler:clean_clone(); 52 session.sasl_handler = session.sasl_handler:clean_clone();
53 elseif status == "success" then 53 elseif status == "success" then
54 module:fire_event("authentication-success", { session = session });
55 local username = nodeprep(session.sasl_handler.username); 54 local username = nodeprep(session.sasl_handler.username);
56 55
57 local ok, err = sm_make_authenticated(session, session.sasl_handler.username); 56 local ok, err = sm_make_authenticated(session, session.sasl_handler.username);
58 if ok then 57 if ok then
58 module:fire_event("authentication-success", { session = session });
59 session.sasl_handler = nil; 59 session.sasl_handler = nil;
60 session:reset_stream(); 60 session:reset_stream();
61 else 61 else
62 module:log("warn", "SASL succeeded but username was invalid"); 62 module:log("warn", "SASL succeeded but username was invalid");
63 session.sasl_handler = session.sasl_handler:clean_clone(); 63 session.sasl_handler = session.sasl_handler:clean_clone();