Software / code / prosody
Comparison
plugins/mod_register_ibr.lua @ 10767:a0166932479f
mod_register_ibr: Fix reporting of registration rejection reason
When the reason is reported as an util.error object the `reason` field
is empty and the reason text should be extacted from the error object.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 23 Apr 2020 19:02:44 +0200 |
| parent | 10368:76eb79d372de |
| child | 10939:99ae457c2459 |
comparison
equal
deleted
inserted
replaced
| 10766:00d2a577204c | 10767:a0166932479f |
|---|---|
| 165 end | 165 end |
| 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"); | |
| 171 local error_type, error_condition, reason; | 170 local error_type, error_condition, reason; |
| 172 local err = user.error; | 171 local err = user.error; |
| 173 if err then | 172 if err then |
| 174 error_type, error_condition, reason = err.type, err.condition, err.text; | 173 error_type, error_condition, reason = err.type, err.condition, err.text; |
| 175 else | 174 else |
| 176 -- COMPAT pre-util.error | 175 -- COMPAT pre-util.error |
| 177 error_type, error_condition, reason = user.error_type, user.error_condition, user.reason; | 176 error_type, error_condition, reason = user.error_type, user.error_condition, user.reason; |
| 178 end | 177 end |
| 178 log("debug", "Registration disallowed by module: %s", reason or "no reason given"); | |
| 179 session.send(st.error_reply(stanza, error_type or "modify", error_condition or "not-acceptable", reason)); | 179 session.send(st.error_reply(stanza, error_type or "modify", error_condition or "not-acceptable", reason)); |
| 180 return true; | 180 return true; |
| 181 end | 181 end |
| 182 | 182 |
| 183 if usermanager_user_exists(username, host) then | 183 if usermanager_user_exists(username, host) then |