@taruvi/refine-providers 1.3.4-beta.4 → 1.3.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/dist/index.cjs +17 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -10
- package/dist/index.d.ts +4 -10
- package/dist/index.js +17 -23
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ var DataLoader__default = /*#__PURE__*/_interopDefault(DataLoader);
|
|
|
11
11
|
|
|
12
12
|
// package.json
|
|
13
13
|
var package_default = {
|
|
14
|
-
version: "1.3.4
|
|
14
|
+
version: "1.3.4"};
|
|
15
15
|
|
|
16
16
|
// src/filterTypes.ts
|
|
17
17
|
var REFINE_OPERATOR_MAP = {
|
|
@@ -1176,27 +1176,20 @@ var isBrowser = typeof window !== "undefined";
|
|
|
1176
1176
|
exports._cachedUser = null;
|
|
1177
1177
|
function authProvider(client) {
|
|
1178
1178
|
const auth = new sdk.Auth(client);
|
|
1179
|
+
function redirectToLogin() {
|
|
1180
|
+
exports._cachedUser = null;
|
|
1181
|
+
auth.login();
|
|
1182
|
+
}
|
|
1179
1183
|
return {
|
|
1180
|
-
login: async (
|
|
1181
|
-
|
|
1182
|
-
if (auth.isUserAuthenticated()) {
|
|
1183
|
-
return {
|
|
1184
|
-
success: true,
|
|
1185
|
-
redirectTo: callbackUrl || "/"
|
|
1186
|
-
};
|
|
1187
|
-
}
|
|
1188
|
-
if (redirect) {
|
|
1189
|
-
auth.login(callbackUrl);
|
|
1184
|
+
login: async () => {
|
|
1185
|
+
if (auth.hasToken()) {
|
|
1190
1186
|
return {
|
|
1191
1187
|
success: true
|
|
1192
1188
|
};
|
|
1193
1189
|
}
|
|
1190
|
+
redirectToLogin();
|
|
1194
1191
|
return {
|
|
1195
|
-
success:
|
|
1196
|
-
error: {
|
|
1197
|
-
name: "LoginError",
|
|
1198
|
-
message: "Login failed. Please try again."
|
|
1199
|
-
}
|
|
1192
|
+
success: true
|
|
1200
1193
|
};
|
|
1201
1194
|
},
|
|
1202
1195
|
logout: async (params = {}) => {
|
|
@@ -1209,19 +1202,20 @@ function authProvider(client) {
|
|
|
1209
1202
|
};
|
|
1210
1203
|
},
|
|
1211
1204
|
check: async () => {
|
|
1212
|
-
if (!auth.
|
|
1213
|
-
return { authenticated: false
|
|
1205
|
+
if (!auth.hasToken()) {
|
|
1206
|
+
return { authenticated: false };
|
|
1207
|
+
}
|
|
1208
|
+
const isValid = await auth.isUserAuthenticated();
|
|
1209
|
+
if (!isValid) {
|
|
1210
|
+
return { authenticated: false };
|
|
1214
1211
|
}
|
|
1215
1212
|
return { authenticated: true };
|
|
1216
1213
|
},
|
|
1217
1214
|
onError: async (error) => {
|
|
1218
1215
|
const status = error?.statusCode || error?.status || error?.response?.status;
|
|
1219
1216
|
if (status === 401) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
redirectTo: "/login",
|
|
1223
|
-
error
|
|
1224
|
-
};
|
|
1217
|
+
redirectToLogin();
|
|
1218
|
+
return { error };
|
|
1225
1219
|
}
|
|
1226
1220
|
if (status === 403) {
|
|
1227
1221
|
return { error };
|