Skip to content

Commit 6538ba1

Browse files
committed
don't call user info if no access token
1 parent f7d3860 commit 6538ba1

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎src/ResponseValidator.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default class ResponseValidator {
9393

9494
response.profile = this.filterProtocolClaims(response.profile);
9595

96-
if (this._settings.loadUserInfo) {
96+
if (this._settings.loadUserInfo && response.access_token) {
9797

9898
Log.info("loading user info");
9999
return this._userInfoService.getClaims(response.access_token).then(claims => {

‎test/ResponseValidator.spec.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,12 @@ describe("ResponseValidator", function() {
344344
});
345345

346346
});
347-
347+
348348
it("should load and merge user info claims when loadUserInfo configured", function(done) {
349349

350350
settings.loadUserInfo = true;
351351
stubResponse.profile = { a: 'apple', b: 'banana' };
352+
stubResponse.access_token = "access_token";
352353
stubUserInfoService.getClaimsResult = Promise.resolve({ c: 'carrot' });
353354

354355
subject.processClaims(stubResponse).then(response => {
@@ -372,6 +373,20 @@ describe("ResponseValidator", function() {
372373
});
373374

374375
});
376+
377+
it("should not load user info claims if no access token", function(done) {
378+
379+
settings.loadUserInfo = true;
380+
stubResponse.profile = { a: 'apple', b: 'banana' };
381+
stubUserInfoService.getClaimsResult = Promise.resolve({ c: 'carrot' });
382+
383+
subject.processClaims(stubResponse).then(response => {
384+
expect(stubUserInfoService.getClaimsWasCalled).to.be.undefined;
385+
expect(subject.mergeClaimsWasCalled).to.be.undefined;
386+
done();
387+
});
388+
389+
});
375390

376391
});
377392

0 commit comments

Comments
 (0)