aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-01-30 15:38:54 +0100
committerKim Alvefur <zash@zash.se>2015-01-30 15:38:54 +0100
commita0f8ff2628e0ae3f27f6b872137a172f9f5bd717 (patch)
tree64984efb8035c0c2f434c2cb941b43782dd8d0ac /core
parent26854f710c5d0c038738ddfda11406ce13a4536a (diff)
downloadprosody-a0f8ff2628e0ae3f27f6b872137a172f9f5bd717.tar.gz
prosody-a0f8ff2628e0ae3f27f6b872137a172f9f5bd717.zip
sessionmanager: Add pre-resource-bind event that would let plugins have a say in resource binding
Diffstat (limited to 'core')
-rw-r--r--core/sessionmanager.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 09920b7d..476de931 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -117,6 +117,16 @@ function bind_resource(session, resource)
if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end
-- We don't support binding multiple resources
+ local event_payload = { session = session, resource = resource };
+ if hosts[session.host].events.fire_event("pre-resource-bind", event_payload) == false then
+ local err = event_payload.error;
+ if err then return nil, err.type, err.condition, err.text; end
+ return nil, "cancel", "not-allowed";
+ else
+ -- In case a plugin wants to poke at it
+ resource = event_payload.resource;
+ end
+
resource = resourceprep(resource);
resource = resource ~= "" and resource or uuid_generate();
--FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing