@overmap-ai/core 1.0.49-fix-error-messaging.1 → 1.0.49-fix-error-messaging.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4313,10 +4313,20 @@ var __publicField = (obj, key, value) => {
4313
4313
  innerError: error2
4314
4314
  });
4315
4315
  }
4316
- console.debug("Forbidden; renewing tokens and retrying.");
4317
- await client.auth.renewTokens();
4318
- console.debug("Successfully renewed tokens; retrying request.");
4319
- return requestToSend.query(queryParams);
4316
+ if (state.authReducer.isLoggedIn) {
4317
+ console.debug("Forbidden; renewing tokens and retrying.");
4318
+ await client.auth.renewTokens();
4319
+ console.debug("Successfully renewed tokens; retrying request.");
4320
+ return requestToSend.query(queryParams);
4321
+ } else {
4322
+ console.debug("Forbidden; user is not logged in.");
4323
+ throw new APIError({
4324
+ message: "Incorrect username or password.",
4325
+ response: errorResponse,
4326
+ discard: true,
4327
+ innerError: error2
4328
+ });
4329
+ }
4320
4330
  }
4321
4331
  throw new APIError({ response: errorResponse, innerError: error2, discard: discardStatuses.includes(status) });
4322
4332
  }
@@ -5131,24 +5141,23 @@ var __publicField = (obj, key, value) => {
5131
5141
  */
5132
5142
  __publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
5133
5143
  const uuid$1 = uuid.v4();
5134
- try {
5135
- const responsePromise = this.enqueueRequest({
5136
- uuid: uuid$1,
5137
- description: "Get token pair",
5138
- method: HttpMethod.POST,
5139
- url: "/api/token/",
5140
- payload: credentials,
5141
- isAuthNeeded: false,
5142
- blockers: [],
5143
- blocks: []
5144
- });
5145
- return [responsePromise.then(parseTokens), uuid$1];
5146
- } catch (e) {
5144
+ const responsePromise = this.enqueueRequest({
5145
+ uuid: uuid$1,
5146
+ description: "Get token pair",
5147
+ method: HttpMethod.POST,
5148
+ url: "/api/token/",
5149
+ payload: credentials,
5150
+ isAuthNeeded: false,
5151
+ checkAuth: false,
5152
+ blockers: [],
5153
+ blocks: []
5154
+ }).then(parseTokens).catch((e) => {
5147
5155
  if (logoutOnFailure) {
5148
5156
  void this.logout().then();
5149
5157
  }
5150
5158
  throw e;
5151
- }
5159
+ });
5160
+ return [responsePromise, uuid$1];
5152
5161
  });
5153
5162
  /**
5154
5163
  * Takes refresh token and gets a new token pair
@@ -5209,7 +5218,7 @@ var __publicField = (obj, key, value) => {
5209
5218
  timedOut = true;
5210
5219
  store.dispatch(markForDeletion(uuid$1));
5211
5220
  store.dispatch(markForDeletion(initialDataUuid));
5212
- reject(new Error(`Request timed out after ${timeout} seconds`));
5221
+ reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
5213
5222
  }, timeout * 1e3);
5214
5223
  });
5215
5224
  const successPromise = promise.then((tokens) => {