Skip to content

Fixed problem with using interceptor with localStorage #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import { OAuthModuleConfig } from "../oauth-module.config";

@Injectable()
export class DefaultOAuthInterceptor implements HttpInterceptor {

private authStorage: OAuthStorage;

constructor(
private authStorage: OAuthStorage,
authService: OAuthService,
private errorHandler: OAuthResourceServerErrorHandler,
@Optional() private moduleConfig: OAuthModuleConfig
) {
this.authStorage = authService.getStorage();
}

private checkUrl(url: string): boolean {
Expand Down
9 changes: 5 additions & 4 deletions angular-oauth2-oidc/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class OAuthService

// extending AuthConfig ist just for LEGACY reasons
// to not break existing code

/**
* The ValidationHandler used to validate received
* id_tokens.
Expand Down Expand Up @@ -312,6 +311,10 @@ export class OAuthService
this._storage = storage;
this.configChanged();
}

public getStorage(): OAuthStorage {
return this._storage;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better suited as a property?

public get storage() : OAuthStorage {
   return this._storage;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, but setStorage is used as method
that's why i also use it like this

/**
* Loads the discovery document to configure most
Expand Down Expand Up @@ -462,7 +465,6 @@ export class OAuthService
}

// this.sessionChecksEnabled = !!doc.check_session_iframe;

return true;
}

Expand Down Expand Up @@ -1138,7 +1140,6 @@ export class OAuthService
}
*/
// let nonceInState = stateParts[0];

if (this.requestAccessToken && !options.disableOAuth2StateCheck) {
let success = this.validateNonceForAccessToken(accessToken, nonceInState);
if (!success) {
Expand Down Expand Up @@ -1546,4 +1547,4 @@ export class OAuthService
return this.tokenValidationHandler.validateSignature(params);
}

}
}