Skip to content

Commit

Permalink
feat(cache-client): update test login endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Harasz committed Jan 7, 2022
1 parent e3303f4 commit 09d8a6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/api/modules/modules_cacheClient_cacheClient_types.md
Expand Up @@ -52,4 +52,4 @@ ___

### TEST\_LOGIN\_ENDPOINT

`Const` **TEST\_LOGIN\_ENDPOINT**: ``"/assets/owner/"``
`Const` **TEST\_LOGIN\_ENDPOINT**: ``"/auth/status"``
12 changes: 7 additions & 5 deletions src/modules/cacheClient/cacheClient.service.ts
Expand Up @@ -77,9 +77,9 @@ export class CacheClient implements ICacheClient {

/**
* @description Interceptor of authentication errors. Queues failed requests and starts authentication process.
*
*
* @param error Intercepted response from failed request
*
*
* @returns Promise, which resolves with result of resending of failed request
*/
async handleError(error: AxiosError) {
Expand Down Expand Up @@ -110,7 +110,7 @@ export class CacheClient implements ICacheClient {
}

/**
* Verifies current session and establishes new one if needed
* Verifies current session and establishes new one if needed
* https://energyweb.atlassian.net/wiki/spaces/MYEN/pages/2303295607/ICL-+ICS+Auth+Process
*/
async login() {
Expand Down Expand Up @@ -319,8 +319,10 @@ export class CacheClient implements ICacheClient {
*/
private async isAuthenticated(): Promise<boolean> {
try {
await this.httpClient.get<Asset[]>(`${TEST_LOGIN_ENDPOINT}${this._signerService.did}`);
return true;
const { data } = await this.httpClient.get<{
user: string | null;
}>(`${TEST_LOGIN_ENDPOINT}`);
return data.user ? data.user === this._signerService.did : false;
} catch (_) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cacheClient/cacheClient.types.ts
Expand Up @@ -28,4 +28,4 @@ export enum SearchType {
Role = "Role",
}

export const TEST_LOGIN_ENDPOINT = "/assets/owner/";
export const TEST_LOGIN_ENDPOINT = "/auth/status";

0 comments on commit 09d8a6b

Please sign in to comment.