Skip to content

Makes sure we don't strip authData or session token from users using masterKey #2348

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

Merged
merged 2 commits into from
Jul 23, 2016
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
30 changes: 30 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,36 @@ describe('Parse.User testing', () => {
});
});

it_exclude_dbs(['postgres'])("user authData should be available in cloudcode (#2342)", (done) => {

Parse.Cloud.define('checkLogin', (req, res) => {
expect(req.user).not.toBeUndefined();
expect(Parse.FacebookUtils.isLinked(req.user)).toBe(true);
res.success();
});

var provider = getMockFacebookProvider();
Parse.User._registerAuthenticationProvider(provider);
Parse.User._logInWith("facebook", {
success: function(model) {
ok(model instanceof Parse.User, "Model should be a Parse.User");
strictEqual(Parse.User.current(), model);
ok(model.extended(), "Should have used subclass.");
strictEqual(provider.authData.id, provider.synchronizedUserId);
strictEqual(provider.authData.access_token, provider.synchronizedAuthToken);
strictEqual(provider.authData.expiration_date, provider.synchronizedExpiration);
ok(model._isLinked("facebook"), "User should be linked to facebook");

Parse.Cloud.run('checkLogin').then(done, done);
},
error: function(model, error) {
console.error(model, error);
ok(false, "linking should have worked");
done();
}
});
});

it_exclude_dbs(['postgres'])("log in with provider and update token", (done) => {
var provider = getMockFacebookProvider();
var secondProvider = getMockFacebookProviderWithIdToken('8675309', 'jenny_valid_token');
Expand Down
2 changes: 1 addition & 1 deletion src/RestQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ function includePath(config, auth, response, path) {
obj.__type = 'Object';
obj.className = includeResponse.className;

if (obj.className == "_User") {
if (obj.className == "_User" && !auth.isMaster) {
delete obj.sessionToken;
delete obj.authData;
}
Expand Down