aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-11-15 22:29:24 +0000
committerMatthew Wild <mwild1@gmail.com>2008-11-15 22:29:24 +0000
commit60292ade15292d2398d91a1af6a578d6a20c9f34 (patch)
tree73a5d330473223ad3e0bfb100a2271afacee4855 /core
parent7fb57614491db05660e8952634aeac67d4ff22f5 (diff)
parent49ab3af4421a0410a723fa8dc7286d4adf736fc9 (diff)
downloadprosody-60292ade15292d2398d91a1af6a578d6a20c9f34.tar.gz
prosody-60292ade15292d2398d91a1af6a578d6a20c9f34.zip
Merge from waqas
Diffstat (limited to 'core')
-rw-r--r--core/sessionmanager.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 82a001c1..9fa00212 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -68,9 +68,13 @@ function make_authenticated(session, username)
return true;
end
+-- returns true, nil on success
+-- returns nil, err_type, err, err_message on failure
function bind_resource(session, resource)
- if not session.username then return false, "auth"; end
- if session.resource then return false, "constraint"; end -- We don't support binding multiple resources
+ if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end
+ 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
+
resource = resource or uuid_generate();
--FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing
@@ -79,7 +83,7 @@ function bind_resource(session, resource)
else
if hosts[session.host].sessions[session.username].sessions[resource] then
-- Resource conflict
- return false, "conflict"; -- TODO kick old resource
+ return nil, "cancel", "conflict", "Resource already exists"; -- TODO kick old resource
end
end