Generate sessionToken with linkWith (#5799)
* Generate sessionToken with linkWith * improve test * Add comment
This commit is contained in:
committed by
peril-parse-community[bot]
parent
9816285205
commit
5341b8248f
@@ -1549,6 +1549,21 @@ describe('Parse.User testing', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('link with provider should return sessionToken', async () => {
|
||||||
|
const provider = getMockFacebookProvider();
|
||||||
|
Parse.User._registerAuthenticationProvider(provider);
|
||||||
|
const user = new Parse.User();
|
||||||
|
user.set('username', 'testLinkWithProvider');
|
||||||
|
user.set('password', 'mypass');
|
||||||
|
await user.signUp();
|
||||||
|
const query = new Parse.Query(Parse.User);
|
||||||
|
const u2 = await query.get(user.id);
|
||||||
|
const model = await u2._linkWith('facebook', {}, { useMasterKey: true });
|
||||||
|
expect(u2.getSessionToken()).toBeDefined();
|
||||||
|
expect(model.getSessionToken()).toBeDefined();
|
||||||
|
expect(u2.getSessionToken()).toBe(model.getSessionToken());
|
||||||
|
});
|
||||||
|
|
||||||
it('link with provider failed', async done => {
|
it('link with provider failed', async done => {
|
||||||
const provider = getMockFacebookProvider();
|
const provider = getMockFacebookProvider();
|
||||||
provider.shouldError = true;
|
provider.shouldError = true;
|
||||||
|
|||||||
@@ -802,7 +802,8 @@ RestWrite.prototype.createSessionTokenIfNeeded = function() {
|
|||||||
if (this.className !== '_User') {
|
if (this.className !== '_User') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.query) {
|
// Don't generate session for updating user (this.query is set) unless authData exists
|
||||||
|
if (this.query && !this.data.authData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user