Software /
code /
prosody-modules
Comparison
mod_sasl2_sm/mod_sasl2_sm.lua @ 5037:8a8100fff580
mod_sasl2_bind2, mod_sasl2_sm: Move sasl2_sm_success to session
...to allow referencing it across multiple different events.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 04 Sep 2022 09:51:36 +0100 |
parent | 5035:baebe7452903 |
child | 5039:c0d243b27e64 |
comparison
equal
deleted
inserted
replaced
5036:9ef5625d0d39 | 5037:8a8100fff580 |
---|---|
37 local h = err.context and err.context.h; | 37 local h = err.context and err.context.h; |
38 sm_result = st.stanza("failed", { xmlns = xmlns_sm, h = h and ("%d"):format(h) or nil }) | 38 sm_result = st.stanza("failed", { xmlns = xmlns_sm, h = h and ("%d"):format(h) or nil }) |
39 :add_error(err); | 39 :add_error(err); |
40 else | 40 else |
41 event.session = resumed.session; -- Update to resumed session | 41 event.session = resumed.session; -- Update to resumed session |
42 event.sasl2_sm_success = resumed; -- To be called after sending final SASL response | 42 event.session.sasl2_sm_success = resumed; -- To be called after sending final SASL response |
43 sm_result = st.stanza("resumed", { xmlns = xmlns_sm, | 43 sm_result = st.stanza("resumed", { xmlns = xmlns_sm, |
44 h = ("%d"):format(event.session.handled_stanza_count); | 44 h = ("%d"):format(event.session.handled_stanza_count); |
45 previd = resumed.id; }); | 45 previd = resumed.id; }); |
46 end | 46 end |
47 | 47 |
64 local enabled, err = mod_smacks.do_enable(event.session, sm_enable); | 64 local enabled, err = mod_smacks.do_enable(event.session, sm_enable); |
65 if not enabled then | 65 if not enabled then |
66 sm_result = st.stanza("failed", { xmlns = xmlns_sm }) | 66 sm_result = st.stanza("failed", { xmlns = xmlns_sm }) |
67 :add_error(err); | 67 :add_error(err); |
68 else | 68 else |
69 event.sasl2_sm_success = enabled; -- To be called after sending final SASL response | 69 event.session.sasl2_sm_success = enabled; -- To be called after sending final SASL response |
70 sm_result = st.stanza("enabled", { | 70 sm_result = st.stanza("enabled", { |
71 xmlns = xmlns_sm; | 71 xmlns = xmlns_sm; |
72 id = enabled.id; | 72 id = enabled.id; |
73 resume = enabled.id and "1" or nil; | 73 resume = enabled.id and "1" or nil; |
74 max = enabled.resume_max; | 74 max = enabled.resume_max; |
79 | 79 |
80 -- Finish and/or clean up after SASL 2 completed | 80 -- Finish and/or clean up after SASL 2 completed |
81 | 81 |
82 module:hook("sasl2/c2s/success", function (event) | 82 module:hook("sasl2/c2s/success", function (event) |
83 -- The authenticate response has already been sent at this point | 83 -- The authenticate response has already been sent at this point |
84 local success = event.sasl2_sm_success; | 84 local success = event.session.sasl2_sm_success; |
85 if success then | 85 if success then |
86 success.finish(); -- Finish enable/resume and sync stanzas | 86 success.finish(); -- Finish enable/resume and sync stanzas |
87 end | 87 end |
88 end, -1100); | 88 end, -1100); |
89 | 89 |