aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-08-01 20:26:00 +0100
committerMatthew Wild <mwild1@gmail.com>2022-08-01 20:26:00 +0100
commitb1f0061da37e72d12a71eb067ae103fe2ae6ca91 (patch)
tree92f37c5da34ae6b16fd0d2141730d1117cdf26f6 /core
parenta88c982ae232f85bbf30401aa7690dbccc482866 (diff)
downloadprosody-b1f0061da37e72d12a71eb067ae103fe2ae6ca91.tar.gz
prosody-b1f0061da37e72d12a71eb067ae103fe2ae6ca91.zip
usermanager: Handle local JIDs being passed to get/set_jid_role()
There is no reasonable fallback for set_jid_role() because users may have multiple roles, so that's an error.
Diffstat (limited to 'core')
-rw-r--r--core/usermanager.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua
index ec782906..09beb6d4 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -10,7 +10,7 @@ local modulemanager = require "core.modulemanager";
local log = require "util.logger".init("usermanager");
local type = type;
local it = require "util.iterators";
-local jid_prep = require "util.jid".prep;
+local jid_prep, jid_split = require "util.jid".prep, require "util.jid".split;
local config = require "core.configmanager";
local sasl_new = require "util.sasl".new;
local storagemanager = require "core.storagemanager";
@@ -196,12 +196,20 @@ end
local function get_jid_role(jid, host)
host = host or "*";
local authz_provider = (host ~= "*" and hosts[host].authz) or global_authz_provider;
+ local jid_node, jid_host = jid_split(jid);
+ if host == jid_host and jid_node then
+ return authz_provider.get_user_default_role(jid_node);
+ end
return authz_provider.get_jid_role(jid);
end
local function set_jid_role(jid, host, role_name)
host = host or "*";
local authz_provider = (host ~= "*" and hosts[host].authz) or global_authz_provider;
+ local _, jid_host = jid_split(jid);
+ if host == jid_host then
+ return nil, "unexpected-local-jid";
+ end
return authz_provider.set_jid_role(jid, role_name)
end