Mercurial > prosody-hg
comparison core/usermanager.lua @ 12993:623fbb5f9b05
core.usermanager: Correct formatting of not implemented error
Spaces, no hyphen, apparently.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Mar 2023 16:51:33 +0200 |
| parents | ead41e25ebc0 |
| children | 7b6e7290265b |
comparison
equal
deleted
inserted
replaced
| 12992:651813914151 | 12993:623fbb5f9b05 |
|---|---|
| 114 return ok, err; | 114 return ok, err; |
| 115 end | 115 end |
| 116 | 116 |
| 117 local function get_account_info(username, host) | 117 local function get_account_info(username, host) |
| 118 local method = hosts[host].users.get_account_info; | 118 local method = hosts[host].users.get_account_info; |
| 119 if not method then return nil, "method-not-supported"; end | 119 if not method then return nil, "method not supported"; end |
| 120 return method(username); | 120 return method(username); |
| 121 end | 121 end |
| 122 | 122 |
| 123 local function user_exists(username, host) | 123 local function user_exists(username, host) |
| 124 if hosts[host].sessions[username] then return true; end | 124 if hosts[host].sessions[username] then return true; end |
| 142 | 142 |
| 143 -- Fallback | 143 -- Fallback |
| 144 local info, err = get_account_info(username, host); | 144 local info, err = get_account_info(username, host); |
| 145 if info and info.enabled ~= nil then | 145 if info and info.enabled ~= nil then |
| 146 return info.enabled; | 146 return info.enabled; |
| 147 elseif err ~= "method-not-implemented" then | 147 elseif err ~= "method not implemented" then |
| 148 -- Storage issues etetc | 148 -- Storage issues etetc |
| 149 return info, err; | 149 return info, err; |
| 150 end | 150 end |
| 151 | 151 |
| 152 -- API unsupported implies users are always enabled | 152 -- API unsupported implies users are always enabled |
| 153 return true; | 153 return true; |
| 154 end | 154 end |
| 155 | 155 |
| 156 local function enable_user(username, host) | 156 local function enable_user(username, host) |
| 157 local method = hosts[host].users.enable; | 157 local method = hosts[host].users.enable; |
| 158 if not method then return nil, "method-not-supported"; end | 158 if not method then return nil, "method not supported"; end |
| 159 local ret, err = method(username); | 159 local ret, err = method(username); |
| 160 if ret then | 160 if ret then |
| 161 prosody.events.fire_event("user-enabled", { username = username, host = host }); | 161 prosody.events.fire_event("user-enabled", { username = username, host = host }); |
| 162 end | 162 end |
| 163 return ret, err; | 163 return ret, err; |
| 164 end | 164 end |
| 165 | 165 |
| 166 local function disable_user(username, host) | 166 local function disable_user(username, host) |
| 167 local method = hosts[host].users.disable; | 167 local method = hosts[host].users.disable; |
| 168 if not method then return nil, "method-not-supported"; end | 168 if not method then return nil, "method not supported"; end |
| 169 local ret, err = method(username); | 169 local ret, err = method(username); |
| 170 if ret then | 170 if ret then |
| 171 prosody.events.fire_event("user-disabled", { username = username, host = host }); | 171 prosody.events.fire_event("user-disabled", { username = username, host = host }); |
| 172 end | 172 end |
| 173 return ret, err; | 173 return ret, err; |
