diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index db6f351637..eba6d8582d 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -20,7 +20,6 @@ export abstract class ApiService { baseUrl: string; identityBaseUrl: string; deviceType: string; - logoutCallback: Function; setUrls: (urls: EnvironmentUrls) => void; postIdentityToken: (request: TokenRequest) => Promise; diff --git a/src/services/api.service.ts b/src/services/api.service.ts index cda9888685..97eed0326f 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -27,11 +27,9 @@ export class ApiService implements ApiServiceAbstraction { baseUrl: string; identityBaseUrl: string; deviceType: string; - logoutCallback: Function; constructor(private tokenService: TokenService, private platformUtilsService: PlatformUtilsService, - logoutCallback: Function) { - this.logoutCallback = logoutCallback; + private logoutCallback: (expired: boolean) => Promise) { this.deviceType = platformUtilsService.getDevice().toString(); } @@ -425,7 +423,7 @@ export class ApiService implements ApiServiceAbstraction { private async handleError(response: Response, tokenError: boolean): Promise { if ((tokenError && response.status === 400) || response.status === 401 || response.status === 403) { - this.logoutCallback(true); + await this.logoutCallback(true); return null; } diff --git a/src/services/nodeApi.service.ts b/src/services/nodeApi.service.ts index 7803eafdc8..e5900f2409 100644 --- a/src/services/nodeApi.service.ts +++ b/src/services/nodeApi.service.ts @@ -12,7 +12,7 @@ import { TokenService } from '../abstractions/token.service'; export class NodeApiService extends ApiService { constructor(tokenService: TokenService, platformUtilsService: PlatformUtilsService, - logoutCallback: Function) { + logoutCallback: (expired: boolean) => Promise) { super(tokenService, platformUtilsService, logoutCallback); } } diff --git a/src/services/sync.service.ts b/src/services/sync.service.ts index 2a001e01a8..c053a34f63 100644 --- a/src/services/sync.service.ts +++ b/src/services/sync.service.ts @@ -30,7 +30,7 @@ export class SyncService implements SyncServiceAbstraction { private settingsService: SettingsService, private folderService: FolderService, private cipherService: CipherService, private cryptoService: CryptoService, private collectionService: CollectionService, private storageService: StorageService, - private messagingService: MessagingService, private logoutCallback: Function) { + private messagingService: MessagingService, private logoutCallback: (expired: boolean) => Promise) { } async getLastSync(): Promise { @@ -134,7 +134,7 @@ export class SyncService implements SyncServiceAbstraction { const stamp = await this.userService.getSecurityStamp(); if (stamp != null && stamp !== response.securityStamp) { if (this.logoutCallback != null) { - this.logoutCallback(true); + await this.logoutCallback(true); } throw new Error('Stamp has changed');