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

Generate sessionToken with linkWith #5799

Merged
5 commits merged into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
const provider = getMockFacebookProvider();
provider.shouldError = true;
Expand Down
3 changes: 2 additions & 1 deletion src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ RestWrite.prototype.createSessionTokenIfNeeded = function() {
if (this.className !== '_User') {
return;
}
if (this.query) {
// Don't generate session for updating user (this.query is set) unless authData exists
if (this.query && !this.data.authData) {
dplewis marked this conversation as resolved.
Show resolved Hide resolved
return;
}
if (
Expand Down