Skip to content

Commit 750f0ef

Browse files
yash-rajpalggazzo
andauthored
Regression: TOTP Modal with new rest api package (#25893)
<!-- This is a pull request template, you do not need to uncomment or remove the comments, they won't show up in the PR text. --> <!-- Your Pull Request name should start with one of the following tags [NEW] For new features [IMPROVE] For an improvement (performance or little improvements) in existing features [FIX] For bug fixes that affect the end-user [BREAK] For pull requests including breaking changes Chore: For small tasks Doc: For documentation --> <!-- Checklist!!! If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. - I have read the Contributing Guide - https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat doc - I have signed the CLA - https://cla-assistant.io/RocketChat/Rocket.Chat - Lint and unit tests pass locally with my changes - I have added tests that prove my fix is effective or that my feature works (if applicable) - I have added necessary documentation (if applicable) - Any dependent changes have been merged and published in downstream modules --> ## Proposed changes (including videos or screenshots) <!-- CHANGELOG --> <!-- Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue below. This description will appear in the release notes if we accept the contribution. --> <!-- END CHANGELOG --> ## Issue(s) <!-- Link the issues being closed by or related to this PR. For example, you can use #594 if this PR closes issue number 594 --> ## Steps to test or reproduce <!-- Mention how you would reproduce the bug if not mentioned on the issue page already. Also mention which screens are going to have the changes if applicable --> ## Further comments <!-- If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... --> Co-authored-by: Guilherme Gazzo <[email protected]>
1 parent 45b6640 commit 750f0ef

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

apps/meteor/app/utils/client/lib/RestApiClient.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ export const APIClient = new RestApiClient({
2828
baseUrl: baseURI.replace(/\/$/, ''),
2929
});
3030

31-
APIClient.use(function (request, next) {
31+
APIClient.use(async function (request, next) {
3232
try {
33-
return next(...request);
34-
} catch (e) {
35-
return new Promise((resolve, reject) => {
33+
return await next(...request);
34+
} catch (error) {
35+
if (!(error instanceof Response) || error.status !== 400) {
36+
throw error;
37+
}
38+
39+
return new Promise(async (resolve, reject) => {
40+
const e = await error.json();
3641
process2faReturn({
3742
error: e,
3843
result: null,

packages/api-client/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ export class RestClient implements RestClientInterface {
161161
...options,
162162
headers: { ...this.getCredentialsAsHeaders(), ...this.headers, ...headers },
163163
method,
164+
}).then(function (response) {
165+
if (!response.ok) {
166+
return Promise.reject(response);
167+
}
168+
return response;
164169
});
165170
}
166171

0 commit comments

Comments
 (0)