@bigbinary/neeto-commons-frontend 2.0.3 → 2.0.4

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.
package/README.md CHANGED
@@ -7,7 +7,7 @@ The commons frontend library for Neeto Applications.
7
7
  Install from npm:
8
8
 
9
9
  ```bash
10
- yarn add "@bigbinary/neeto-commons-frontend@2.0.3"
10
+ yarn add "@bigbinary/neeto-commons-frontend@2.0.4"
11
11
  ```
12
12
 
13
13
  This package relies on the host project's tailwind configuration. So add
@@ -262,11 +262,20 @@ var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
262
262
  };
263
263
 
264
264
  var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(error) {
265
+ var _error$response;
266
+
267
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) !== 401) return error;
265
268
  resetAuthTokens();
266
- setTimeout(function () {
267
- var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
268
- window.location.href = redirectTo;
269
- }, 300);
269
+ var _error$config$redirec = error.config.redirectOnError,
270
+ redirectOnError = _error$config$redirec === void 0 ? true : _error$config$redirec;
271
+
272
+ if (redirectOnError) {
273
+ setTimeout(function () {
274
+ var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
275
+ window.location.href = redirectTo;
276
+ }, 300);
277
+ }
278
+
270
279
  return error;
271
280
  };
272
281
 
@@ -283,9 +292,12 @@ var showErrorToastr = function showErrorToastr(error) {
283
292
  };
284
293
 
285
294
  var redirect404 = function redirect404(error) {
286
- var _error$response;
295
+ var _error$response2;
296
+
297
+ var _error$config$redirec2 = error.config.redirectOnError,
298
+ redirectOnError = _error$config$redirec2 === void 0 ? true : _error$config$redirec2;
287
299
 
288
- if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404) {
300
+ if (redirectOnError && ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 404) {
289
301
  window.location.href = "/page-not-found";
290
302
  }
291
303
 
package/initializers.js CHANGED
@@ -252,11 +252,20 @@ var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
252
252
  };
253
253
 
254
254
  var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(error) {
255
+ var _error$response;
256
+
257
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) !== 401) return error;
255
258
  resetAuthTokens();
256
- setTimeout(function () {
257
- var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
258
- window.location.href = redirectTo;
259
- }, 300);
259
+ var _error$config$redirec = error.config.redirectOnError,
260
+ redirectOnError = _error$config$redirec === void 0 ? true : _error$config$redirec;
261
+
262
+ if (redirectOnError) {
263
+ setTimeout(function () {
264
+ var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
265
+ window.location.href = redirectTo;
266
+ }, 300);
267
+ }
268
+
260
269
  return error;
261
270
  };
262
271
 
@@ -273,9 +282,12 @@ var showErrorToastr = function showErrorToastr(error) {
273
282
  };
274
283
 
275
284
  var redirect404 = function redirect404(error) {
276
- var _error$response;
285
+ var _error$response2;
286
+
287
+ var _error$config$redirec2 = error.config.redirectOnError,
288
+ redirectOnError = _error$config$redirec2 === void 0 ? true : _error$config$redirec2;
277
289
 
278
- if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404) {
290
+ if (redirectOnError && ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 404) {
279
291
  window.location.href = "/page-not-found";
280
292
  }
281
293
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",