Software /
code /
prosody
Comparison
plugins/mod_register.lua @ 5165:39bb9344f194
mod_register: Fire event to allow blocking user registration
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Mon, 01 Oct 2012 21:07:20 +0200 |
parent | 5098:fca8b5946f6f |
child | 5371:706206e191e8 |
comparison
equal
deleted
inserted
replaced
5163:854f6d9aee2d | 5165:39bb9344f194 |
---|---|
221 local username, password = nodeprep(data.username), data.password; | 221 local username, password = nodeprep(data.username), data.password; |
222 data.username, data.password = nil, nil; | 222 data.username, data.password = nil, nil; |
223 local host = module.host; | 223 local host = module.host; |
224 if not username or username == "" then | 224 if not username or username == "" then |
225 session.send(st.error_reply(stanza, "modify", "not-acceptable", "The requested username is invalid.")); | 225 session.send(st.error_reply(stanza, "modify", "not-acceptable", "The requested username is invalid.")); |
226 return true; | |
227 end | |
228 local user = { username = username , host = host, allowed = true } | |
229 module:fire_event("user-registering", user); | |
230 if not user.allowed then | |
231 session.send(st.error_reply(stanza, "modify", "not-acceptable", "The requested username is forbidden.")); | |
226 elseif usermanager_user_exists(username, host) then | 232 elseif usermanager_user_exists(username, host) then |
227 session.send(st.error_reply(stanza, "cancel", "conflict", "The requested username already exists.")); | 233 session.send(st.error_reply(stanza, "cancel", "conflict", "The requested username already exists.")); |
228 else | 234 else |
229 -- TODO unable to write file, file may be locked, etc, what's the correct error? | 235 -- TODO unable to write file, file may be locked, etc, what's the correct error? |
230 local error_reply = st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk."); | 236 local error_reply = st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk."); |