aboutsummaryrefslogtreecommitdiffstats
path: root/core/sessionmanager.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2008-11-16 03:16:53 +0500
committerWaqas Hussain <waqas20@gmail.com>2008-11-16 03:16:53 +0500
commit49ab3af4421a0410a723fa8dc7286d4adf736fc9 (patch)
tree98dfeeab9c8ec9cab5ccbce1507564d358355336 /core/sessionmanager.lua
parent803c3e4a90f04c2c37e76be1e79fd49a61d159a0 (diff)
downloadprosody-49ab3af4421a0410a723fa8dc7286d4adf736fc9.tar.gz
prosody-49ab3af4421a0410a723fa8dc7286d4adf736fc9.zip
Code cleanup for resource binding
Diffstat (limited to 'core/sessionmanager.lua')
-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