comparison plugins/mod_register_ibr.lua @ 8488:95706e0f19fc

mod_register_ibr: Allow modules that do pre-registration checks to specify a reason for rejection The current hardcoded text may not always be accurate
author Kim Alvefur <zash@zash.se>
date Wed, 27 Dec 2017 00:44:21 +0100
parents 0e02c6de5c02
children 9918f324a0be
comparison
equal deleted inserted replaced
8487:91f6815de26a 8488:95706e0f19fc
145 end 145 end
146 local user = { username = username , host = host, additional = data, ip = session.ip, session = session, allowed = true } 146 local user = { username = username , host = host, additional = data, ip = session.ip, session = session, allowed = true }
147 module:fire_event("user-registering", user); 147 module:fire_event("user-registering", user);
148 if not user.allowed then 148 if not user.allowed then
149 log("debug", "Registration disallowed by module"); 149 log("debug", "Registration disallowed by module");
150 session.send(st.error_reply(stanza, "modify", "not-acceptable", "The requested username is forbidden.")); 150 session.send(st.error_reply(stanza, "modify", "not-acceptable", user.reason));
151 elseif usermanager_user_exists(username, host) then 151 elseif usermanager_user_exists(username, host) then
152 log("debug", "Attempt to register with existing username"); 152 log("debug", "Attempt to register with existing username");
153 session.send(st.error_reply(stanza, "cancel", "conflict", "The requested username already exists.")); 153 session.send(st.error_reply(stanza, "cancel", "conflict", "The requested username already exists."));
154 else 154 else
155 -- TODO unable to write file, file may be locked, etc, what's the correct error? 155 -- TODO unable to write file, file may be locked, etc, what's the correct error?