Mercurial > prosody-hg
comparison core/usermanager.lua @ 12906:e282c92ded0e
core.usermanager: Fire events when enabling and disabling users
Allow modules to act on this state change, e.g. kick accounts etc.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 23 Feb 2023 16:25:31 +0100 |
| parents | 8473a516004f |
| children | cdb996637b08 |
comparison
equal
deleted
inserted
replaced
| 12905:8473a516004f | 12906:e282c92ded0e |
|---|---|
| 153 end | 153 end |
| 154 | 154 |
| 155 local function enable_user(username, host) | 155 local function enable_user(username, host) |
| 156 local method = hosts[host].users.enable; | 156 local method = hosts[host].users.enable; |
| 157 if not method then return nil, "method-not-supported"; end | 157 if not method then return nil, "method-not-supported"; end |
| 158 return method(username); | 158 local ret, err = method(username); |
| 159 if ret then | |
| 160 prosody.events.fire_event("user-enabled", { username = username, host = host }); | |
| 161 end | |
| 162 return ret, err; | |
| 159 end | 163 end |
| 160 | 164 |
| 161 local function disable_user(username, host) | 165 local function disable_user(username, host) |
| 162 local method = hosts[host].users.disable; | 166 local method = hosts[host].users.disable; |
| 163 if not method then return nil, "method-not-supported"; end | 167 if not method then return nil, "method-not-supported"; end |
| 164 return method(username); | 168 local ret, err = method(username); |
| 169 if ret then | |
| 170 prosody.events.fire_event("user-disabled", { username = username, host = host }); | |
| 171 end | |
| 172 return ret, err; | |
| 165 end | 173 end |
| 166 | 174 |
| 167 local function users(host) | 175 local function users(host) |
| 168 return hosts[host].users.users(); | 176 return hosts[host].users.users(); |
| 169 end | 177 end |
