Skip to content

Commit

Permalink
Merge pull request #379 from energywebfoundation/revert-374-bug/ICS-1…
Browse files Browse the repository at this point in the history
…24_random_unauthorized_to_cache

Revert "bug/ICS-124 random unauthorized to cache server "
  • Loading branch information
jrhender committed Dec 10, 2021
2 parents 90c086a + 43c00be commit 441a52a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/modules/cacheClient/cacheClient.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ 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}`;
}
this.refresh_token = refreshToken;
this.pubKeyAndIdentityToken = pubKeyAndIdentityToken;
} 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.failedRequests = this.failedRequests.filter((callback) => callback());
}
Expand Down

0 comments on commit 441a52a

Please sign in to comment.