Skip to content

Commit 7ada130

Browse files
committed
fix
1 parent d3ba9d9 commit 7ada130

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

angular-oauth2-oidc/src/auth.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,12 @@ export class AuthConfig {
200200
* Normally, the discovey document's url starts with the url of the issuer.
201201
*/
202202
public skipIssuerCheck? = false;
203+
204+
/**
205+
* According to rfc6749 it is recommended (but not required) that the auth
206+
* server exposes the access_token's life time in seconds.
207+
* This is a fallback value for the case this value is not exposed.
208+
*/
209+
public fallbackAccessTokenExpirationTimeInSec?: number;
203210

204211
}

angular-oauth2-oidc/src/interceptors/default-oauth.interceptor.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { OAuthService } from '../oauth-service';
33
import { OAuthStorage } from '../types';
44
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse, HttpErrorResponse } from '@angular/common/http';
55
import {Observable} from 'rxjs/Observable';
6-
import { map, catchError } from 'rxjs/operators';
7-
import { of } from 'rxjs/observable/of';
6+
import { catchError } from 'rxjs/operators';
87
import { OAuthResourceServerErrorHandler } from "./resource-server-error-handler";
98
import { OAuthModuleConfig } from "../oauth-module.config";
109

10+
import 'rxjs/add/operator/catch';
11+
1112
@Injectable()
1213
export class DefaultOAuthInterceptor implements HttpInterceptor {
1314

@@ -45,9 +46,7 @@ export class DefaultOAuthInterceptor implements HttpInterceptor {
4546
req = req.clone({ headers });
4647
}
4748

48-
return next.handle(req).pipe(
49-
catchError(err => this.errorHandler.handleError(err))
50-
);
49+
return next.handle(req).catch(err => this.errorHandler.handleError(err));
5150

5251
}
5352

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {HttpResponse} from '@angular/common/http';
22
import { Observable, } from 'rxjs/Observable';
3-
import { _throw } from 'rxjs/observable/throw';
3+
import 'rxjs/add/observable/throw';
44

55
export abstract class OAuthResourceServerErrorHandler {
66
abstract handleError(err: HttpResponse<any>): Observable<any>;
@@ -9,7 +9,7 @@ export abstract class OAuthResourceServerErrorHandler {
99
export class OAuthNoopResourceServerErrorHandler implements OAuthResourceServerErrorHandler {
1010

1111
handleError(err: HttpResponse<any>): Observable<any> {
12-
return _throw(err);
12+
return Observable.throw(err);
1313
}
1414

1515
}

angular-oauth2-oidc/src/oauth-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ export class OAuthService
11491149
}
11501150

11511151
if (this.requestAccessToken) {
1152-
this.storeAccessTokenResponse(accessToken, null, parts['expires_in']);
1152+
this.storeAccessTokenResponse(accessToken, null, parts['expires_in'] | this.fallbackAccessTokenExpirationTimeInSec);
11531153
}
11541154

11551155
if (!this.oidc) {
@@ -1175,9 +1175,10 @@ export class OAuthService
11751175
this.storeIdToken(result);
11761176
this.storeSessionState(sessionState);
11771177
this.eventsSubject.next(new OAuthSuccessEvent('token_received'));
1178+
if (this.clearHashAfterLogin) location.hash = '';
11781179
this.callOnTokenReceivedIfExists(options);
11791180
this.inImplicitFlow = false;
1180-
if (this.clearHashAfterLogin) location.hash = '';
1181+
11811182
})
11821183
.catch(reason => {
11831184
this.eventsSubject.next(new OAuthErrorEvent('token_validation_error', reason));

angular-oauth2-oidc/src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-oauth2-oidc",
3-
"version": "3.1.3",
3+
"version": "3.1.5",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/manfredsteyer/angular-oauth2-oidc"

0 commit comments

Comments
 (0)