Merge branch 'develop' into release/1.2.12

This commit is contained in:
Marcel Klehr 2013-10-12 20:29:49 +02:00
commit 614ca6bd90
3 changed files with 22 additions and 22 deletions

View File

@ -77,28 +77,22 @@ exports.getPadId = function(readOnlyId, callback)
* returns a the padId and readonlyPadId in an object for any id * returns a the padId and readonlyPadId in an object for any id
* @param {String} padIdOrReadonlyPadId read only id or real pad id * @param {String} padIdOrReadonlyPadId read only id or real pad id
*/ */
exports.getIds = function(padIdOrReadonlyPadId, callback) { exports.getIds = function(id, callback) {
var handleRealPadId = function () { if (id.indexOf("r.") == 0)
exports.getReadOnlyId(padIdOrReadonlyPadId, function (err, value) { exports.getPadId(id, function (err, value) {
callback(null, {
readOnlyPadId: value,
padId: padIdOrReadonlyPadId,
readonly: false
});
});
}
if (padIdOrReadonlyPadId.indexOf("r.") != 0)
return handleRealPadId();
exports.getPadId(padIdOrReadonlyPadId, function (err, value) {
if(ERR(err, callback)) return; if(ERR(err, callback)) return;
if (value == null)
return handleRealPadId();
callback(null, { callback(null, {
readOnlyPadId: padIdOrReadonlyPadId, readOnlyPadId: id,
padId: value, padId: value, // Might be null, if this is an unknown read-only id
readonly: true readonly: true
}); });
}); });
else
exports.getReadOnlyId(id, function (err, value) {
callback(null, {
readOnlyPadId: value,
padId: id,
readonly: false
});
});
} }

View File

@ -42,6 +42,11 @@ exports.checkAccess = function (padID, sessionCookie, token, password, callback)
{ {
var statusObject; var statusObject;
if(!padID) {
callback(null, {accessStatus: "deny"});
return;
}
// a valid session is required (api-only mode) // a valid session is required (api-only mode)
if(settings.requireSession) if(settings.requireSession)
{ {

View File

@ -144,15 +144,16 @@ exports.handleDisconnect = function(client)
*/ */
exports.handleMessage = function(client, message) exports.handleMessage = function(client, message)
{ {
if(message == null) if(message == null)
{ {
messageLogger.warn("Message is null!");
return; return;
} }
if(!message.type) if(!message.type)
{ {
messageLogger.warn("Message has no type attribute!"); return;
}
if(!sessioninfos[client.id]) {
messageLogger.warn("Dropped message from an unknown connection.")
return; return;
} }