Fix create wrong _Session for Facebook login
This commit is contained in:
@@ -175,17 +175,26 @@ describe('rest create', () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
var newUserSignedUpByFacebookObjectId;
|
||||
rest.create(config, auth.nobody(config), '_User', data)
|
||||
.then((r) => {
|
||||
expect(typeof r.response.objectId).toEqual('string');
|
||||
expect(typeof r.response.createdAt).toEqual('string');
|
||||
expect(typeof r.response.sessionToken).toEqual('string');
|
||||
newUserSignedUpByFacebookObjectId = r.response.objectId;
|
||||
return rest.create(config, auth.nobody(config), '_User', data);
|
||||
}).then((r) => {
|
||||
expect(typeof r.response.objectId).toEqual('string');
|
||||
expect(typeof r.response.createdAt).toEqual('string');
|
||||
expect(typeof r.response.username).toEqual('string');
|
||||
expect(typeof r.response.updatedAt).toEqual('string');
|
||||
expect(r.response.objectId).toEqual(newUserSignedUpByFacebookObjectId);
|
||||
return rest.find(config, auth.master(config),
|
||||
'_Session', {sessionToken: r.response.sessionToken});
|
||||
}).then((response) => {
|
||||
expect(response.results.length).toEqual(1);
|
||||
var output = response.results[0];
|
||||
expect(output.user.objectId).toEqual(newUserSignedUpByFacebookObjectId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -178,7 +178,11 @@ RestWrite.prototype.setRequiredFieldsIfNeeded = function() {
|
||||
this.data.updatedAt = this.updatedAt;
|
||||
if (!this.query) {
|
||||
this.data.createdAt = this.updatedAt;
|
||||
this.data.objectId = cryptoUtils.newObjectId();
|
||||
|
||||
// Only assign new objectId if we are creating new object
|
||||
if (!this.data.objectId) {
|
||||
this.data.objectId = cryptoUtils.newObjectId();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
||||
Reference in New Issue
Block a user