Checking if object has defined key for Pointer constraints in liveQuery

* 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.

* Removing dangling variable that is never used

* Checking if object has defined key for Pointer constraints in liveQuery

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)
This commit is contained in:
Simonas Karuzas
2016-04-14 17:24:04 +03:00
committed by Florent Vilmart
parent fc1cdd4408
commit 686cc4ab95

View File

@@ -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
);