Comparison

core/sessionmanager.lua @ 6599:f93e1b2ec327

sessionmanager: Return 'not-allowed' error instead of the non-existent 'already-bound' error when client tries to bind a resource twice on the same stream (thanks Flow) fixes issue #484.
author Matthew Wild <mwild1@gmail.com>
date Tue, 24 Mar 2015 15:57:46 +0000
parent 5459:3a821511b9ec
child 6602:61b6a4fc65f1
child 7495:caee8a32983a
comparison
equal deleted inserted replaced
6598:4b4852c4f96a 6599:f93e1b2ec327
111 111
112 -- returns true, nil on success 112 -- returns true, nil on success
113 -- returns nil, err_type, err, err_message on failure 113 -- returns nil, err_type, err, err_message on failure
114 function bind_resource(session, resource) 114 function bind_resource(session, resource)
115 if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end 115 if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end
116 if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end 116 if session.resource then return nil, "cancel", "not-allowed", "Cannot bind multiple resources on a single connection"; end
117 -- We don't support binding multiple resources 117 -- We don't support binding multiple resources
118 118
119 resource = resourceprep(resource); 119 resource = resourceprep(resource);
120 resource = resource ~= "" and resource or uuid_generate(); 120 resource = resource ~= "" and resource or uuid_generate();
121 --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing 121 --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing