Software /
code /
prosody
Comparison
core/sessionmanager.lua @ 6563:f0a2bdfd0cea
Merge with 0.10
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 31 Jan 2015 12:25:00 +0000 |
parent | 6561:bae84401a02c |
child | 6602:61b6a4fc65f1 |
comparison
equal
deleted
inserted
replaced
6562:2b5ced5ca31f | 6563:f0a2bdfd0cea |
---|---|
114 -- returns nil, err_type, err, err_message on failure | 114 -- returns nil, err_type, err, err_message on failure |
115 function bind_resource(session, resource) | 115 function bind_resource(session, resource) |
116 if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end | 116 if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end |
117 if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end | 117 if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end |
118 -- We don't support binding multiple resources | 118 -- We don't support binding multiple resources |
119 | |
120 local event_payload = { session = session, resource = resource }; | |
121 if hosts[session.host].events.fire_event("pre-resource-bind", event_payload) == false then | |
122 local err = event_payload.error; | |
123 if err then return nil, err.type, err.condition, err.text; end | |
124 return nil, "cancel", "not-allowed"; | |
125 else | |
126 -- In case a plugin wants to poke at it | |
127 resource = event_payload.resource; | |
128 end | |
119 | 129 |
120 resource = resourceprep(resource); | 130 resource = resourceprep(resource); |
121 resource = resource ~= "" and resource or uuid_generate(); | 131 resource = resource ~= "" and resource or uuid_generate(); |
122 --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing | 132 --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing |
123 | 133 |