strapi-custom-auth 1.2.33 → 1.2.35

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.
@@ -75,16 +75,28 @@ const fetchInterceptor = (storage) => {
75
75
  const byPass = init.headers ? await init.headers.get("x-by-pass") : false;
76
76
  if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData || byPass == true) {
77
77
  console.log("---skip renewal---");
78
- return originalFetch(input, init);
78
+ try {
79
+ const response = await originalFetch(input, init);
80
+ console.log("---response--", JSON.stringify(response));
81
+ console.log("---response, json--", await response.json());
82
+ return response;
83
+ } catch (e) {
84
+ console.log("----fetch---, e", e);
85
+ console.log("----fetch---, e", JSON.stringify(e));
86
+ }
79
87
  }
80
88
  console.log("---renewal---");
81
89
  let token = storage.getItem("jwtToken").replace(/"/g, "");
82
90
  console.log("---token---", token);
83
91
  if (isTokenExpired(token)) {
92
+ console.log("---Token IS EXPIRED---");
84
93
  try {
85
94
  token = await renewToken(storage, originalFetch);
95
+ console.log("---Token IS EXPIRED---, token", token);
86
96
  console.log("Token renewed successfully");
87
97
  } catch (error) {
98
+ console.log("---Token IS EXPIRED---, error", error);
99
+ console.log("---Token IS EXPIRED---, error", JSON.stringify(error));
88
100
  console.error("Token renewal failed. Logging out...");
89
101
  storage.clear();
90
102
  if (!window.location.pathname.includes("/admin/auth/login")) {
@@ -111,8 +123,14 @@ const fetchInterceptor = (storage) => {
111
123
  };
112
124
  try {
113
125
  const response = await originalFetch(input, modifiedInit);
126
+ console.log("----originalFetch /2, input", input);
127
+ console.log("----originalFetch /2, input", JSON.stringify(input));
128
+ console.log("----originalFetch /2, modifiedInit", modifiedInit);
129
+ console.log("----originalFetch /2, modifiedInit", JSON.stringify(modifiedInit));
130
+ console.log("----originalFetch /2, response", response);
114
131
  if (!response.ok) {
115
132
  const errorData = await response.json();
133
+ console.log("----originalFetch /2, errorData", JSON.stringify(errorData));
116
134
  console.log("Fetch error:", errorData.error?.message);
117
135
  if (response.status === 401) {
118
136
  storage.clear();
@@ -74,16 +74,28 @@ const fetchInterceptor = (storage) => {
74
74
  const byPass = init.headers ? await init.headers.get("x-by-pass") : false;
75
75
  if (url.includes("/admin/renew-token") || url.includes("/auth/login") || url.includes("repos/strapi/strapi/releases/latest") || url.includes("/admin/init") || init.body instanceof FormData || byPass == true) {
76
76
  console.log("---skip renewal---");
77
- return originalFetch(input, init);
77
+ try {
78
+ const response = await originalFetch(input, init);
79
+ console.log("---response--", JSON.stringify(response));
80
+ console.log("---response, json--", await response.json());
81
+ return response;
82
+ } catch (e) {
83
+ console.log("----fetch---, e", e);
84
+ console.log("----fetch---, e", JSON.stringify(e));
85
+ }
78
86
  }
79
87
  console.log("---renewal---");
80
88
  let token = storage.getItem("jwtToken").replace(/"/g, "");
81
89
  console.log("---token---", token);
82
90
  if (isTokenExpired(token)) {
91
+ console.log("---Token IS EXPIRED---");
83
92
  try {
84
93
  token = await renewToken(storage, originalFetch);
94
+ console.log("---Token IS EXPIRED---, token", token);
85
95
  console.log("Token renewed successfully");
86
96
  } catch (error) {
97
+ console.log("---Token IS EXPIRED---, error", error);
98
+ console.log("---Token IS EXPIRED---, error", JSON.stringify(error));
87
99
  console.error("Token renewal failed. Logging out...");
88
100
  storage.clear();
89
101
  if (!window.location.pathname.includes("/admin/auth/login")) {
@@ -110,8 +122,14 @@ const fetchInterceptor = (storage) => {
110
122
  };
111
123
  try {
112
124
  const response = await originalFetch(input, modifiedInit);
125
+ console.log("----originalFetch /2, input", input);
126
+ console.log("----originalFetch /2, input", JSON.stringify(input));
127
+ console.log("----originalFetch /2, modifiedInit", modifiedInit);
128
+ console.log("----originalFetch /2, modifiedInit", JSON.stringify(modifiedInit));
129
+ console.log("----originalFetch /2, response", response);
113
130
  if (!response.ok) {
114
131
  const errorData = await response.json();
132
+ console.log("----originalFetch /2, errorData", JSON.stringify(errorData));
115
133
  console.log("Fetch error:", errorData.error?.message);
116
134
  if (response.status === 401) {
117
135
  storage.clear();
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.33",
2
+ "version": "1.2.35",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {