Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #5207 #5257

Merged
merged 2 commits into from
Dec 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,59 @@ describe('ParseLiveQueryServer', function() {
expect(originalObject.updatedAt).not.toBeUndefined();
});

it('can inflate user object', async () => {
const parseLiveQueryServer = new ParseLiveQueryServer({});
const userJSON = {
username: 'test',
ACL: {},
createdAt: '2018-12-21T23:09:51.784Z',
sessionToken: 'r:1234',
updatedAt: '2018-12-21T23:09:51.784Z',
objectId: 'NhF2u9n72W',
__type: 'Object',
className: '_User',
_hashed_password: '1234',
_email_verify_token: '1234',
};

const originalUserJSON = {
username: 'test',
ACL: {},
createdAt: '2018-12-21T23:09:51.784Z',
sessionToken: 'r:1234',
updatedAt: '2018-12-21T23:09:51.784Z',
objectId: 'NhF2u9n72W',
__type: 'Object',
className: '_User',
_hashed_password: '12345',
_email_verify_token: '12345',
};

const message = {
currentParseObject: userJSON,
originalParseObject: originalUserJSON,
};
parseLiveQueryServer._inflateParseObject(message);

const object = message.currentParseObject;
expect(object instanceof Parse.Object).toBeTruthy();
expect(object.get('_hashed_password')).toBeUndefined();
expect(object.get('_email_verify_token')).toBeUndefined();
expect(object.className).toEqual('_User');
expect(object.id).toBe('NhF2u9n72W');
expect(object.createdAt).not.toBeUndefined();
expect(object.updatedAt).not.toBeUndefined();

const originalObject = message.originalParseObject;
expect(originalObject instanceof Parse.Object).toBeTruthy();
expect(originalObject.get('_hashed_password')).toBeUndefined();
expect(originalObject.get('_email_verify_token')).toBeUndefined();
expect(originalObject.className).toEqual('_User');
expect(originalObject.id).toBe('NhF2u9n72W');
expect(originalObject.createdAt).not.toBeUndefined();
expect(originalObject.updatedAt).not.toBeUndefined();
});

it('can match undefined ACL', function(done) {
const parseLiveQueryServer = new ParseLiveQueryServer({});
const client = {};
Expand Down Expand Up @@ -1314,7 +1367,7 @@ describe('ParseLiveQueryServer', function() {
new Parse.ACL()
);
liveQueryRole.id = 'abcdef1234';
callback(liveQueryRole)
callback(liveQueryRole);
return Promise.resolve();
},
};
Expand Down
3 changes: 3 additions & 0 deletions src/LiveQuery/ParseLiveQueryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { runLiveQueryEventHandlers } from '../triggers';
import { getAuthForSessionToken, Auth } from '../Auth';
import { getCacheController } from '../Controllers';
import LRU from 'lru-cache';
import UserRouter from '../Routers/UsersRouter';

class ParseLiveQueryServer {
clients: Map;
Expand Down Expand Up @@ -98,13 +99,15 @@ class ParseLiveQueryServer {
_inflateParseObject(message: any): void {
// Inflate merged object
const currentParseObject = message.currentParseObject;
UserRouter.removeHiddenProperties(currentParseObject);
let className = currentParseObject.className;
let parseObject = new Parse.Object(className);
parseObject._finishFetch(currentParseObject);
message.currentParseObject = parseObject;
// Inflate original object
const originalParseObject = message.originalParseObject;
if (originalParseObject) {
UserRouter.removeHiddenProperties(originalParseObject);
className = originalParseObject.className;
parseObject = new Parse.Object(className);
parseObject._finishFetch(originalParseObject);
Expand Down