Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
make logout callback async
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed May 16, 2018
1 parent 7112911 commit 799c90a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/abstractions/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export abstract class ApiService {
baseUrl: string;
identityBaseUrl: string;
deviceType: string;
logoutCallback: Function;

setUrls: (urls: EnvironmentUrls) => void;
postIdentityToken: (request: TokenRequest) => Promise<IdentityTokenResponse | IdentityTwoFactorResponse>;
Expand Down
6 changes: 2 additions & 4 deletions src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>) {
this.deviceType = platformUtilsService.getDevice().toString();
}

Expand Down Expand Up @@ -425,7 +423,7 @@ export class ApiService implements ApiServiceAbstraction {

private async handleError(response: Response, tokenError: boolean): Promise<ErrorResponse> {
if ((tokenError && response.status === 400) || response.status === 401 || response.status === 403) {
this.logoutCallback(true);
await this.logoutCallback(true);
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/nodeApi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>) {
super(tokenService, platformUtilsService, logoutCallback);
}
}
4 changes: 2 additions & 2 deletions src/services/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>) {
}

async getLastSync(): Promise<Date> {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 799c90a

Please sign in to comment.