Skip to content

Commit

Permalink
fix: resume failed requests
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Dec 9, 2021
1 parent bbf3ceb commit f53a5d9
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/modules/cacheClient/cacheClient.service.ts
Expand Up @@ -56,21 +56,20 @@ export class CacheClient implements ICacheClient {
}
if (await this.isAuthenticated()) {
this.refresh_token = refreshToken;
return;
}
} catch {}

const pubKeyAndIdentityToken = await this._signerService.publicKeyAndIdentityToken();
const {
data: { refreshToken, token },
} = await this.httpClient.post<{ token: string; refreshToken: string }>("/login", {
identityToken: pubKeyAndIdentityToken.identityToken,
});
if (!this.isBrowser) {
this.httpClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
} catch {
const pubKeyAndIdentityToken = await this._signerService.publicKeyAndIdentityToken();
const {
data: { refreshToken, token },
} = await this.httpClient.post<{ token: string; refreshToken: string }>("/login", {
identityToken: pubKeyAndIdentityToken.identityToken,
});
if (!this.isBrowser) {
this.httpClient.defaults.headers.common["Authorization"] = `Bearer ${token}`;
}
this.refresh_token = refreshToken;
this.pubKeyAndIdentityToken = pubKeyAndIdentityToken;
}
this.refresh_token = refreshToken;
this.pubKeyAndIdentityToken = pubKeyAndIdentityToken;

this.failedRequests = this.failedRequests.filter((callback) => callback());
}
Expand Down

0 comments on commit f53a5d9

Please sign in to comment.