From 69f21efaf03f70f64c49e51d887642581bf6f6b4 Mon Sep 17 00:00:00 2001 From: erdemcaygor Date: Fri, 24 Oct 2025 12:28:35 +0300 Subject: [PATCH] refactoring --- .../services/memory-token-storage.service.ts | 24 ++++++++----------- .../oauth/src/lib/services/oauth.service.ts | 6 ++++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/npm/ng-packs/packages/oauth/src/lib/services/memory-token-storage.service.ts b/npm/ng-packs/packages/oauth/src/lib/services/memory-token-storage.service.ts index 40b5d8d736..8866d4d0a3 100644 --- a/npm/ng-packs/packages/oauth/src/lib/services/memory-token-storage.service.ts +++ b/npm/ng-packs/packages/oauth/src/lib/services/memory-token-storage.service.ts @@ -6,35 +6,31 @@ import { AbpLocalStorageService } from '@abp/ng.core'; providedIn: 'root', }) export class MemoryTokenStorageService implements OAuthStorage { - private keysShouldStoreLocalstorage = ['PKCE_verifier', 'abpOAuthClientId', 'abp_session', 'refresh_token', 'granted_scopes', 'id_token_claims_obj']; - private keysShouldStoreInMemory = ['access_token']; + private keysShouldStoreInMemory = ['access_token', 'id_token', 'expires_at', 'id_token_claims_obj', 'id_token_expires_at', 'id_token_stored_at', 'access_token_stored_at', 'abpOAuthClientId', 'granted_scopes']; private data = new Map(); private localStorageService = inject(AbpLocalStorageService); getItem(key: string): string { - console.log('getItem -->>', key); - if (this.keysShouldStoreInMemory.includes(key)) { - return this.data.get(key) || null; + if (!this.keysShouldStoreInMemory.includes(key)) { + return this.localStorageService.getItem(key); } - return this.localStorageService.getItem(key); + return this.data.get(key) || null; } removeItem(key: string): void { - if (this.keysShouldStoreInMemory.includes(key)) { - this.data.delete(key); + if (!this.keysShouldStoreInMemory.includes(key)) { + this.localStorageService.removeItem(key); return; } - this.localStorageService.removeItem(key); + this.data.delete(key); } setItem(key: string, data: string): void { - if (this.keysShouldStoreInMemory.includes(key)) { - console.log('setItem -->', key, data); - this.data.set(key, data); + if (!this.keysShouldStoreInMemory.includes(key)) { + this.localStorageService.setItem(key, data); return; } - console.log('setItem -->', key, data); - this.localStorageService.setItem(key, data); + this.data.set(key, data); } clear() { diff --git a/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts b/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts index a25c3f6138..d3d3ca9dec 100644 --- a/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts +++ b/npm/ng-packs/packages/oauth/src/lib/services/oauth.service.ts @@ -110,7 +110,11 @@ export class AbpOAuthService implements IAuthService { this.document.defaultView?.location.replace('/authorize'); return Promise.resolve(); } - return this.oAuthService.refreshToken(); + try { + return this.oAuthService.refreshToken(); + } catch (error) { + return Promise.resolve(); + } } getAccessTokenExpiration(): number {