Comparison

plugins/mod_register.lua @ 8201:a0ad62a269df

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 28 Aug 2017 21:05:12 +0200
parent 8194:ba9cd8447578
child 8452:4796fdcb7146
comparison
equal deleted inserted replaced
8185:e89320b8a789 8201:a0ad62a269df
89 end 89 end
90 90
91 features:add_child(register_stream_feature); 91 features:add_child(register_stream_feature);
92 end); 92 end);
93 93
94 -- Password change and account deletion handler
94 local function handle_registration_stanza(event) 95 local function handle_registration_stanza(event)
95 local session, stanza = event.origin, event.stanza; 96 local session, stanza = event.origin, event.stanza;
96 local log = session.log or module._log; 97 local log = session.log or module._log;
97 98
98 local query = stanza.tags[1]; 99 local query = stanza.tags[1];
128 else 129 else
129 local username = nodeprep(query:get_child_text("username")); 130 local username = nodeprep(query:get_child_text("username"));
130 local password = query:get_child_text("password"); 131 local password = query:get_child_text("password");
131 if username and password then 132 if username and password then
132 if username == session.username then 133 if username == session.username then
133 if usermanager_set_password(username, password, session.host) then 134 if usermanager_set_password(username, password, session.host, session.resource) then
134 session.send(st.reply(stanza)); 135 session.send(st.reply(stanza));
135 else 136 else
136 -- TODO unable to write file, file may be locked, etc, what's the correct error? 137 -- TODO unable to write file, file may be locked, etc, what's the correct error?
137 session.send(st.error_reply(stanza, "wait", "internal-server-error")); 138 session.send(st.error_reply(stanza, "wait", "internal-server-error"));
138 end 139 end
205 end 206 end
206 throttle_cache:set(ip, throttle); 207 throttle_cache:set(ip, throttle);
207 return throttle:poll(1); 208 return throttle:poll(1);
208 end 209 end
209 210
211 -- In-band registration
210 module:hook("stanza/iq/jabber:iq:register:query", function(event) 212 module:hook("stanza/iq/jabber:iq:register:query", function(event)
211 local session, stanza = event.origin, event.stanza; 213 local session, stanza = event.origin, event.stanza;
212 local log = session.log or module._log; 214 local log = session.log or module._log;
213 215
214 if not(allow_registration) or session.type ~= "c2s_unauthed" then 216 if not(allow_registration) or session.type ~= "c2s_unauthed" then