Skip to content

Commit 1b8cf03

Browse files
Merge 35fe088 into c05102b
2 parents c05102b + 35fe088 commit 1b8cf03

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

spec/AuthenticationAdapters.spec.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const authenticationLoader = require('../lib/Adapters/Auth');
55
const path = require('path');
66
const responses = {
77
gpgames: { playerId: 'userId' },
8-
instagram: { data: { id: 'userId' } },
8+
instagram: { id: 'userId' },
99
janrainengage: { stat: 'ok', profile: { identifier: 'userId' } },
1010
janraincapture: { stat: 'ok', result: 'userId' },
1111
line: { userId: 'userId' },
@@ -492,7 +492,15 @@ describe('instagram auth adapter', () => {
492492
'https://graph.instagram.com/me?fields=id&access_token=the_token'
493493
);
494494
});
495-
495+
it('response object without data child', async () => {
496+
spyOn(httpsRequest, 'get').and.callFake(() => {
497+
return Promise.resolve({ id: 'userId' });
498+
});
499+
await instagram.validateAuthData({ id: 'userId', access_token: 'the_token' }, {});
500+
expect(httpsRequest.get).toHaveBeenCalledWith(
501+
'https://graph.instagram.com/me?fields=id&access_token=the_token'
502+
);
503+
});
496504
it('should pass in api url', async () => {
497505
spyOn(httpsRequest, 'get').and.callFake(() => {
498506
return Promise.resolve({ data: { id: 'userId' } });

src/Adapters/Auth/instagram.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function validateAuthData(authData) {
88
const apiURL = authData.apiURL || defaultURL;
99
const path = `${apiURL}me?fields=id&access_token=${authData.access_token}`;
1010
return httpsRequest.get(path).then(response => {
11-
if (response && response.data && response.data.id == authData.id) {
11+
const user = response.data ? response.data : response
12+
if (user && user.id == authData.id) {
1213
return;
1314
}
1415
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Instagram auth is invalid for this user.');

0 commit comments

Comments
 (0)