Skip to content

Commit 53edcfd

Browse files
authored
fix: Parse.User.signUp() does not pass context to Cloud Code (parse-community#1527)
1 parent e4cdc30 commit 53edcfd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/ParseUser.js

+6
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ class ParseUser extends ParseObject {
425425
if (options.hasOwnProperty('installationId')) {
426426
signupOptions.installationId = options.installationId;
427427
}
428+
if (
429+
options.hasOwnProperty('context') &&
430+
Object.prototype.toString.call(options.context) === '[object Object]'
431+
) {
432+
signupOptions.context = options.context;
433+
}
428434

429435
const controller = CoreManager.getUserController();
430436
return controller.signUp(this, attrs, signupOptions);

src/__tests__/ParseUser-test.js

+24
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,30 @@ describe('ParseUser', () => {
16811681
expect(user.existed()).toBe(true);
16821682
});
16831683

1684+
it('can signup with context', async () => {
1685+
CoreManager.setRESTController({
1686+
ajax() {},
1687+
request() {
1688+
return Promise.resolve(
1689+
{
1690+
objectId: 'uid3',
1691+
username: 'username',
1692+
sessionToken: '123abc',
1693+
},
1694+
200
1695+
);
1696+
},
1697+
});
1698+
const controller = CoreManager.getRESTController();
1699+
jest.spyOn(controller, 'request');
1700+
const context = { a: 'a' };
1701+
const user = new ParseUser();
1702+
user.setUsername('name');
1703+
user.setPassword('pass');
1704+
await user.signUp(null, { context });
1705+
expect(controller.request.mock.calls[0][3].context).toEqual(context);
1706+
});
1707+
16841708
it('can verify user password', async () => {
16851709
ParseUser.enableUnsafeCurrentUser();
16861710
ParseUser._clearCache();

0 commit comments

Comments
 (0)