Software / code / prosody
Comparison
plugins/mod_register_ibr.lua @ 10363:1010a1ff8d21
mod_register_ibr: Allow registartion rejection reason as util.error object
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 01 Nov 2019 18:09:13 +0100 |
| parent | 10290:b2ce3300f26a |
| child | 10368:76eb79d372de |
comparison
equal
deleted
inserted
replaced
| 10362:c05444119e9e | 10363:1010a1ff8d21 |
|---|---|
| 166 | 166 |
| 167 local user = { username = username, password = password, host = host, additional = data, ip = session.ip, session = session, allowed = true } | 167 local user = { username = username, password = password, host = host, additional = data, ip = session.ip, session = session, allowed = true } |
| 168 module:fire_event("user-registering", user); | 168 module:fire_event("user-registering", user); |
| 169 if not user.allowed then | 169 if not user.allowed then |
| 170 log("debug", "Registration disallowed by module: %s", user.reason or "no reason given"); | 170 log("debug", "Registration disallowed by module: %s", user.reason or "no reason given"); |
| 171 -- TODO This could use util.error | 171 local error_type, error_condition, reason; |
| 172 session.send(st.error_reply(stanza, user.error_type or "modify", user.error_condition or "not-acceptable", user.reason)); | 172 local err = user.error; |
| 173 if err then | |
| 174 error_type, error_condition, reason = err.type, err.condition, err.text; | |
| 175 else | |
| 176 -- COMPAT pre-util.error | |
| 177 error_type, error_condition, reason = user.error_type, user.error_condition, user.reason; | |
| 178 end | |
| 179 session.send(st.error_reply(stanza, error_type or "modify", error_condition or "not-acceptable", reason)); | |
| 173 return true; | 180 return true; |
| 174 end | 181 end |
| 175 | 182 |
| 176 if usermanager_user_exists(username, host) then | 183 if usermanager_user_exists(username, host) then |
| 177 log("debug", "Attempt to register with existing username"); | 184 log("debug", "Attempt to register with existing username"); |