Skip to content

Commit

Permalink
fix: signinSilent fails when no user is available
Browse files Browse the repository at this point in the history
This fixes an issue introduced in 1.6.0
(14ed108).
If there is no user available, signinSilent won't work because of the
following TypeError:

```
oidc-client.min.js:formatted:8872 Error during OIDC autologin TypeError: Cannot read property 'id_token' of null
    at oidc-client.min.js:formatted:8232
```
  • Loading branch information
Michael Weibel committed Dec 20, 2018
1 parent 3e135b9 commit 0c9ea9c
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 65 deletions.
62 changes: 31 additions & 31 deletions dist/oidc-client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/oidc-client.min.js

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions lib/oidc-client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/oidc-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class UserManager extends OidcClient {
return this._useRefreshToken(args);
}
else {
args.id_token_hint = args.id_token_hint || (this.settings.includeIdTokenInSilentRenew && user.id_token);
args.id_token_hint = args.id_token_hint || (this.settings.includeIdTokenInSilentRenew && user && user.id_token);
return this._signinSilentIframe(args);
}
});
Expand Down
14 changes: 14 additions & 0 deletions test/unit/UserManager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe("UserManager", function () {

navArgs.silentRequestTimeout.should.equal(123);
done();
return Promise.resolve()
}
subject.signinSilent();
});
Expand All @@ -122,6 +123,7 @@ describe("UserManager", function () {
subject._signin = function(args, nav, navArgs){
navArgs.silentRequestTimeout.should.equal(234);
done();
return Promise.resolve()
}
subject.signinSilent({silentRequestTimeout:234});
});
Expand All @@ -136,9 +138,21 @@ describe("UserManager", function () {
subject._signin = function(args, nav, navArgs){
args.prompt.should.equal("foo");
done();
return Promise.resolve()
}
subject.signinSilent({prompt:"foo"});
});

it("should work when having no User present", function(done) {
settings.silent_redirect_uri = "http://client/silent_callback";
subject = new UserManager(settings);

subject._signin = function(){
done();
return Promise.resolve()
}
subject.signinSilent({prompt:"foo"});
})
});

});

0 comments on commit 0c9ea9c

Please sign in to comment.