Skip to content

Commit

Permalink
[feat] Add refresh token mechanism on aim ui
Browse files Browse the repository at this point in the history
  • Loading branch information
KaroMourad committed Jan 4, 2024
1 parent 9c0e8a2 commit d40081c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
9 changes: 3 additions & 6 deletions aim/web/ui/src/services/NetworkService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,9 @@ class NetworkService {
}

if (response.status >= 400) {
// @TODO: Add refresh token api
// return await this.checkCredentials(response, url, () =>
// this.makeAPIRequest(partUrl, options),
// );
return reject(body);
return await this.checkCredentials(response, url, () =>
this.request(url, options),
);
}

return resolve({ body, headers });
Expand Down Expand Up @@ -347,7 +345,6 @@ class NetworkService {
}
}

// @TODO: Add refresh token api and after use the "checkCredentials" function
public async checkCredentials<T>(
response: Response,
endpoint: string,
Expand Down
24 changes: 10 additions & 14 deletions aim/web/ui/src/services/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,16 @@ function createAPIRequestWrapper<ResponseDataType>(
exceptionHandler(body);
}

// @TODO: Add refresh token api
// return await checkCredentials<ResponseDataType>(
// response,
// url,
// () =>
// createAPIRequestWrapper<ResponseDataType>(
// url,
// options,
// stream,
// ).call(exceptionHandler),
// );

return;
return await checkCredentials<ResponseDataType>(
response,
url,
() =>
createAPIRequestWrapper<ResponseDataType>(
url,
options,
stream,
).call(exceptionHandler),
);
}
const data = stream ? response.body : await response.json();

Expand Down Expand Up @@ -304,7 +301,6 @@ async function parseResponse<T>(response: Response): Promise<T> {
}
}

// @TODO: Add refresh token api and after use the "checkCredentials" function
async function checkCredentials<T>(
response: Response,
endpoint: string,
Expand Down

0 comments on commit d40081c

Please sign in to comment.