From acb294dba7c91a8aa6d3ee8a0f440ac6b41b422c Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Mon, 11 Apr 2016 14:26:42 +0300 Subject: [PATCH 1/4] Removing sessionToken and authData from _User objects included in a query This bug caused sessionToken to be replaced on client side to some old sessionToken from DB. --- src/RestQuery.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/RestQuery.js b/src/RestQuery.js index e825a5448c..767f03b637 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -477,8 +477,9 @@ function includePath(config, auth, response, path) { obj.__type = 'Object'; obj.className = includeResponse.className; - if(className == "_User"){ + if (obj.className == "_User") { delete obj.sessionToken; + delete obj.authData; } replace[obj.objectId] = obj; } From 7c785fd69956dd00386f99bc904827ff033f1ae0 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Tue, 12 Apr 2016 10:06:58 +0300 Subject: [PATCH 2/4] Removing dangling variable that is never used --- src/RestQuery.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/RestQuery.js b/src/RestQuery.js index 767f03b637..68b50173f3 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -450,7 +450,6 @@ function includePath(config, auth, response, path) { return response; } let pointersHash = {}; - var className = null; var objectIds = {}; for (var pointer of pointers) { let className = pointer.className; From 4e5381c4e5ac391adbc5854cef4950f5a71a31a9 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Thu, 14 Apr 2016 16:08:25 +0300 Subject: [PATCH 3/4] Checking if object has defined key for Pointer constraints in liveQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there is a liveQuery subscription, with Pointer type constrains (e.g query.equalTo('user', Parse.User.current())), and new object has undefined value for that field, we get this error: error: Uncaught internal server error. [TypeError: Cannot read property 'className' of undefined] TypeError: Cannot read property 'className' of undefined at matchesKeyConstraints (…/node_modules/parse-server/lib/LiveQuery/QueryTools.js:145:51) --- src/LiveQuery/QueryTools.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index 8a47f25c79..605e49b1c0 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -141,6 +141,7 @@ function matchesKeyConstraints(object, key, constraints) { if (constraints.__type) { if (constraints.__type === 'Pointer') { return ( + typeof object[key] !== 'undefined' && constraints.className === object[key].className && constraints.objectId === object[key].objectId ); From 029cb21d2d398cc649625401a1460fb1dbba7c84 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Fri, 22 Jul 2016 11:17:18 +0300 Subject: [PATCH 4/4] LiveQuery constrains matching fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When constrains == null, we get “Uncaught internal server error” --- src/LiveQuery/QueryTools.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index 605e49b1c0..f2cb5edcbe 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -117,6 +117,9 @@ function matchesQuery(object: any, query: any): boolean { * Determines whether an object matches a single key's constraints */ function matchesKeyConstraints(object, key, constraints) { + if (constraints === null) { + return false; + } var i; if (key === '$or') { for (i = 0; i < constraints.length; i++) {