Skip to content

Commit aa3d6e6

Browse files
authored
Can unlink without provider (cloud code) (#971)
This is specifically for facebook since you can't register a auth provider in cloud code (FB doesn't exist). Removes duplicate logic (linkWith handles the providers) ``` Cannot read property 'getAuthType' of undefined ``` Note: I can't add an integration test for this. `integration/server.js` uses /node_modules/parse `integration/tests` uses /lib/node If they could both use /lib/node that would open the door for testing different cloud code function.
1 parent 103f05e commit aa3d6e6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/ParseUser.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,13 @@ class ParseUser extends ParseObject {
213213

214214
/**
215215
* Unlinks a user from a service.
216+
*
217+
* @param {String|AuthProvider} provider Name of auth provider or {@link https://parseplatform.org/Parse-SDK-JS/api/master/AuthProvider.html AuthProvider}
218+
* @param {Object} options MasterKey / SessionToken
219+
* @return {Promise} A promise that is fulfilled when the unlinking
220+
* finishes.
216221
*/
217-
_unlinkFrom(provider: any, options?: FullOptions) {
218-
if (typeof provider === 'string') {
219-
provider = authProviders[provider];
220-
}
222+
_unlinkFrom(provider: any, options?: FullOptions): Promise<ParseUser> {
221223
return this.linkWith(provider, { authData: null }, options).then(() => {
222224
this._synchronizeAuthData(provider);
223225
return Promise.resolve(this);

src/__tests__/ParseUser-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ describe('ParseUser', () => {
849849
const user = new ParseUser();
850850
jest.spyOn(user, 'linkWith')
851851
.mockImplementationOnce((authProvider, authData, saveOptions) => {
852-
expect(authProvider).toEqual(provider);
852+
expect(authProvider).toEqual(provider.getAuthType());
853853
expect(authData).toEqual({ authData: null});
854854
expect(saveOptions).toEqual({ useMasterKey: true });
855855
return Promise.resolve();
@@ -1007,6 +1007,6 @@ describe('ParseUser', () => {
10071007

10081008
await user._unlinkFrom('testProvider');
10091009
const authProvider = user.linkWith.mock.calls[0][0];
1010-
expect(authProvider.getAuthType()).toBe('testProvider');
1010+
expect(authProvider).toBe('testProvider');
10111011
});
10121012
});

0 commit comments

Comments
 (0)