diff --git a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts index 3b59c4d6ff..50e545ca1a 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts @@ -58,10 +58,14 @@ export abstract class AuthFlowStrategy { return Promise.resolve(); } - return this.oAuthService.refreshToken() as Promise; + return this.refreshToken(); }) .catch(this.catchError); } + + protected refreshToken() { + return this.oAuthService.refreshToken().catch(() => clearOAuthStorage()); + } } export class AuthCodeFlowStrategy extends AuthFlowStrategy { @@ -111,9 +115,10 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { ) .subscribe(() => { if (this.oAuthService.getRefreshToken()) { - this.oAuthService.refreshToken(); + this.refreshToken(); } else { this.oAuthService.logOut(); + this.removeRememberMe(); this.appConfigService.get().subscribe(res => { this.configState.setState(res); }); @@ -184,6 +189,13 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy { }), ); } + + protected refreshToken() { + return this.oAuthService.refreshToken().catch(() => { + clearOAuthStorage(); + this.removeRememberMe(); + }); + } } export const AUTH_FLOW_STRATEGY = {