Software /
code /
prosody
Comparison
core/usermanager.lua @ 11473:afe80b64e209
usermanager: expose set_roles through API
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Mon, 22 Mar 2021 21:24:57 +0100 |
parent | 10695:52886aad9ee1 |
child | 11745:3a2d58a39872 |
comparison
equal
deleted
inserted
replaced
11472:c32753ceb0f0 | 11473:afe80b64e209 |
---|---|
156 end | 156 end |
157 | 157 |
158 return roles; | 158 return roles; |
159 end | 159 end |
160 | 160 |
161 local function set_roles(jid, host, roles) | |
162 if host and not hosts[host] then return false; end | |
163 if type(jid) ~= "string" then return false; end | |
164 | |
165 jid = jid_bare(jid); | |
166 host = host or "*"; | |
167 | |
168 local actor_user, actor_host = jid_split(jid); | |
169 | |
170 local authz_provider = (host ~= "*" and hosts[host].authz) or global_authz_provider; | |
171 if actor_user and actor_host == host then -- Local user | |
172 return authz_provider.set_user_roles(actor_user, roles) | |
173 else -- Remote entity | |
174 return authz_provider.set_jid_roles(jid, roles) | |
175 end | |
176 end | |
177 | |
161 local function is_admin(jid, host) | 178 local function is_admin(jid, host) |
162 local roles = get_roles(jid, host); | 179 local roles = get_roles(jid, host); |
163 return roles and roles["prosody:admin"]; | 180 return roles and roles["prosody:admin"]; |
164 end | 181 end |
165 | 182 |
174 delete_user = delete_user; | 191 delete_user = delete_user; |
175 users = users; | 192 users = users; |
176 get_sasl_handler = get_sasl_handler; | 193 get_sasl_handler = get_sasl_handler; |
177 get_provider = get_provider; | 194 get_provider = get_provider; |
178 get_roles = get_roles; | 195 get_roles = get_roles; |
196 set_roles = set_roles; | |
179 is_admin = is_admin; | 197 is_admin = is_admin; |
180 }; | 198 }; |