comparison mod_sasl2/mod_sasl2.lua @ 5249:828e5e443613

mod_sasl2: Fire authentication-{success,failure} events like mod_saslauth
author Matthew Wild <mwild1@gmail.com>
date Tue, 14 Mar 2023 17:13:46 +0000
parents e9cf361982d5
children 6526b670e66d
comparison
equal deleted inserted replaced
5248:b8b2bf0c1b4b 5249:828e5e443613
119 error_text = err_msg; 119 error_text = err_msg;
120 }); 120 });
121 end 121 end
122 122
123 module:hook("sasl2/c2s/failure", function (event) 123 module:hook("sasl2/c2s/failure", function (event)
124 module:fire_event("authentication-failure", event);
124 local session, condition, text = event.session, event.message, event.error_text; 125 local session, condition, text = event.session, event.message, event.error_text;
125 local failure = st.stanza("failure", { xmlns = xmlns_sasl2 }) 126 local failure = st.stanza("failure", { xmlns = xmlns_sasl2 })
126 :tag(condition, { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl" }):up(); 127 :tag(condition, { xmlns = "urn:ietf:params:xml:ns:xmpp-sasl" }):up();
127 if text then 128 if text then
128 failure:text_tag("text", text); 129 failure:text_tag("text", text);
163 event.success:text_tag("authorization-identifier", jid_join(session.username, session.host, session.resource)); 164 event.success:text_tag("authorization-identifier", jid_join(session.username, session.host, session.resource));
164 session.send(event.success); 165 session.send(event.success);
165 end, -1000); 166 end, -1000);
166 167
167 module:hook("sasl2/c2s/success", function (event) 168 module:hook("sasl2/c2s/success", function (event)
169 module:fire_event("authentication-success", event);
168 local session = event.session; 170 local session = event.session;
169 local features = st.stanza("stream:features"); 171 local features = st.stanza("stream:features");
170 module:fire_event("stream-features", { origin = session, features = features }); 172 module:fire_event("stream-features", { origin = session, features = features });
171 session.send(features); 173 session.send(features);
172 end, -1500); 174 end, -1500);