Skip to content

Commit 9d836ee

Browse files
authored
Use an empty object as default value of options for Google Sign in (#6844)
* Use an empty object as default value of options for Google Sign in * add test case * Update test case to specifically for google auth
1 parent dc502d1 commit 9d836ee

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

spec/index.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,4 +531,27 @@ describe('server', () => {
531531
})
532532
.catch(done.fail);
533533
});
534+
535+
it('should not fail when Google signin is introduced without the optional clientId', done => {
536+
const jwt = require('jsonwebtoken');
537+
538+
reconfigureServer({
539+
auth: { google: {} }
540+
})
541+
.then(() => {
542+
const fakeClaim = {
543+
iss: 'https://accounts.google.com',
544+
aud: 'secret',
545+
exp: Date.now(),
546+
sub: 'the_user_id',
547+
};
548+
const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } };
549+
spyOn(jwt, 'decode').and.callFake(() => fakeDecodedToken);
550+
spyOn(jwt, 'verify').and.callFake(() => fakeClaim);
551+
const user = new Parse.User();
552+
user.linkWith('google', { authData: { id: 'the_user_id', id_token: 'the_token' }})
553+
.then(done);
554+
})
555+
.catch(done.fail);
556+
});
534557
});

src/Adapters/Auth/google.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async function verifyIdToken({ id_token: token, id }, { clientId }) {
113113
}
114114

115115
// Returns a promise that fulfills if this user id is valid.
116-
function validateAuthData(authData, options) {
116+
function validateAuthData(authData, options = {}) {
117117
return verifyIdToken(authData, options);
118118
}
119119

0 commit comments

Comments
 (0)