Skip to content

Commit

Permalink
#92
Browse files Browse the repository at this point in the history
  • Loading branch information
manfredsteyer committed Sep 14, 2017
1 parent 8c4880e commit 1dd4765
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 38 deletions.
33 changes: 19 additions & 14 deletions angular-oauth2-oidc/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,7 @@ export class OAuthService
}

private restartRefreshTimerIfStillLoggedIn(): void {
if (this.hasValidAccessToken()) {
this.setupAccessTokenTimer();
}

if (this.hasValidIdToken()) {
this.setupIdTokenTimer();
}
this.setupExpirationTimers();
}

private setupSessionCheck() {
Expand Down Expand Up @@ -218,16 +212,23 @@ export class OAuthService

this.clearAccessTokenTimer();
this.clearIdTokenTimer();
this.setupExpirationTimers();

if (this.hasValidAccessToken()) {
this.setupAccessTokenTimer();
}
});
}

if (this.hasValidIdToken()) {
this.setupIdTokenTimer();
}
private setupExpirationTimers(): void {
let idTokenExp = this.getIdTokenExpiration() || Number.MAX_VALUE;
let accessTokenExp = this.getAccessTokenExpiration() || Number.MAX_VALUE;
let useAccessTokenExp = accessTokenExp <= idTokenExp;

});
if (this.hasValidAccessToken() && useAccessTokenExp ) {
this.setupAccessTokenTimer();
}

if (this.hasValidIdToken() && !useAccessTokenExp ) {
this.setupIdTokenTimer();
}
}

private setupAccessTokenTimer(): void {
Expand Down Expand Up @@ -1285,6 +1286,7 @@ export class OAuthService
* as milliseconds since 1970.
*/
public getAccessTokenExpiration(): number {
if (!this._storage.getItem('expires_at')) return null;
return parseInt(this._storage.getItem('expires_at'), 10);
}

Expand All @@ -1302,6 +1304,9 @@ export class OAuthService
* as milliseconds since 1970.
*/
public getIdTokenExpiration(): number {

if (!this._storage.getItem('id_token_expires_at')) return null;

return parseInt(this._storage.getItem('id_token_expires_at'), 10);
}

Expand Down
2 changes: 1 addition & 1 deletion angular-oauth2-oidc/src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-oauth2-oidc",
"version": "2.1.2",
"version": "2.1.3",
"repository": {
"type": "git",
"url": "https://github.com/manfredsteyer/angular-oauth2-oidc"
Expand Down
23 changes: 0 additions & 23 deletions npm-debug.log

This file was deleted.

Empty file removed npm-debug.log.1616803090
Empty file.

0 comments on commit 1dd4765

Please sign in to comment.