diff --git a/docs/api/modules/modules_cacheClient_cacheClient_types.md b/docs/api/modules/modules_cacheClient_cacheClient_types.md index 79e6be48..c2ab3778 100644 --- a/docs/api/modules/modules_cacheClient_cacheClient_types.md +++ b/docs/api/modules/modules_cacheClient_cacheClient_types.md @@ -52,4 +52,4 @@ ___ ### TEST\_LOGIN\_ENDPOINT -• `Const` **TEST\_LOGIN\_ENDPOINT**: ``"/assets/owner/"`` +• `Const` **TEST\_LOGIN\_ENDPOINT**: ``"/auth/status"`` diff --git a/src/modules/cacheClient/cacheClient.service.ts b/src/modules/cacheClient/cacheClient.service.ts index f926a617..96f44f12 100644 --- a/src/modules/cacheClient/cacheClient.service.ts +++ b/src/modules/cacheClient/cacheClient.service.ts @@ -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) { @@ -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() { @@ -319,8 +319,10 @@ export class CacheClient implements ICacheClient { */ private async isAuthenticated(): Promise { try { - await this.httpClient.get(`${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; } diff --git a/src/modules/cacheClient/cacheClient.types.ts b/src/modules/cacheClient/cacheClient.types.ts index 5d7353f3..e1f9906a 100644 --- a/src/modules/cacheClient/cacheClient.types.ts +++ b/src/modules/cacheClient/cacheClient.types.ts @@ -28,4 +28,4 @@ export enum SearchType { Role = "Role", } -export const TEST_LOGIN_ENDPOINT = "/assets/owner/"; +export const TEST_LOGIN_ENDPOINT = "/auth/status";