react-redux-django-auth 1.3.2 → 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.d.mts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +46 -1
- package/dist/index.mjs +27 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ interface LoginHookReturn {
|
|
|
13
13
|
loading: boolean;
|
|
14
14
|
formData: any;
|
|
15
15
|
error: any;
|
|
16
|
+
currentUser: any;
|
|
16
17
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
18
|
onSubmit: (e: React.FormEvent) => Promise<void>;
|
|
18
19
|
isAuthenticated: boolean | null;
|
|
@@ -112,4 +113,37 @@ type AuthProviderProps = {
|
|
|
112
113
|
};
|
|
113
114
|
declare const AuthProvider: React$1.FC<AuthProviderProps>;
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
/**
|
|
117
|
+
* A type representing a single error message string.
|
|
118
|
+
*/
|
|
119
|
+
type ErrorMessage = string;
|
|
120
|
+
/**
|
|
121
|
+
* A type representing an array of error messages.
|
|
122
|
+
*/
|
|
123
|
+
type ErrorMessageArray = string[];
|
|
124
|
+
/**
|
|
125
|
+
* A type representing an object where keys map to either a single error message
|
|
126
|
+
* or an array of error messages.
|
|
127
|
+
*/
|
|
128
|
+
type ErrorMessageObject = {
|
|
129
|
+
[key: string]: ErrorMessage | ErrorMessageArray;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* A union type for all possible error message inputs.
|
|
133
|
+
*/
|
|
134
|
+
type ErrorMessageType = ErrorMessage | ErrorMessageArray | ErrorMessageObject;
|
|
135
|
+
/**
|
|
136
|
+
* Extracts and flattens various error message formats into a single array of strings.
|
|
137
|
+
*
|
|
138
|
+
* This function can handle:
|
|
139
|
+
* - A single string: Returns an array with that string.
|
|
140
|
+
* - An array of strings: Returns the array as is.
|
|
141
|
+
* - An object: Iterates through the object's values and extracts all strings
|
|
142
|
+
* and strings from arrays into a single flattened array.
|
|
143
|
+
*
|
|
144
|
+
* @param errorMsg The error message(s) to extract, which can be a string, array, or object.
|
|
145
|
+
* @returns A flattened array of error message strings.
|
|
146
|
+
*/
|
|
147
|
+
declare const extractErrorMessages: (errorMsg: ErrorMessageType) => string[];
|
|
148
|
+
|
|
149
|
+
export { AuthProvider, extractErrorMessages, useActivate, useAuthicatedUser, useChangeAuthenticatedUserPassword, useFacebookAuth, useGoogleAuth, useLogin, useLogout, usePasswordConfirm, useResetPassword, useSignup };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ interface LoginHookReturn {
|
|
|
13
13
|
loading: boolean;
|
|
14
14
|
formData: any;
|
|
15
15
|
error: any;
|
|
16
|
+
currentUser: any;
|
|
16
17
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
18
|
onSubmit: (e: React.FormEvent) => Promise<void>;
|
|
18
19
|
isAuthenticated: boolean | null;
|
|
@@ -112,4 +113,37 @@ type AuthProviderProps = {
|
|
|
112
113
|
};
|
|
113
114
|
declare const AuthProvider: React$1.FC<AuthProviderProps>;
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
/**
|
|
117
|
+
* A type representing a single error message string.
|
|
118
|
+
*/
|
|
119
|
+
type ErrorMessage = string;
|
|
120
|
+
/**
|
|
121
|
+
* A type representing an array of error messages.
|
|
122
|
+
*/
|
|
123
|
+
type ErrorMessageArray = string[];
|
|
124
|
+
/**
|
|
125
|
+
* A type representing an object where keys map to either a single error message
|
|
126
|
+
* or an array of error messages.
|
|
127
|
+
*/
|
|
128
|
+
type ErrorMessageObject = {
|
|
129
|
+
[key: string]: ErrorMessage | ErrorMessageArray;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* A union type for all possible error message inputs.
|
|
133
|
+
*/
|
|
134
|
+
type ErrorMessageType = ErrorMessage | ErrorMessageArray | ErrorMessageObject;
|
|
135
|
+
/**
|
|
136
|
+
* Extracts and flattens various error message formats into a single array of strings.
|
|
137
|
+
*
|
|
138
|
+
* This function can handle:
|
|
139
|
+
* - A single string: Returns an array with that string.
|
|
140
|
+
* - An array of strings: Returns the array as is.
|
|
141
|
+
* - An object: Iterates through the object's values and extracts all strings
|
|
142
|
+
* and strings from arrays into a single flattened array.
|
|
143
|
+
*
|
|
144
|
+
* @param errorMsg The error message(s) to extract, which can be a string, array, or object.
|
|
145
|
+
* @returns A flattened array of error message strings.
|
|
146
|
+
*/
|
|
147
|
+
declare const extractErrorMessages: (errorMsg: ErrorMessageType) => string[];
|
|
148
|
+
|
|
149
|
+
export { AuthProvider, extractErrorMessages, useActivate, useAuthicatedUser, useChangeAuthenticatedUserPassword, useFacebookAuth, useGoogleAuth, useLogin, useLogout, usePasswordConfirm, useResetPassword, useSignup };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ function _array_like_to_array(arr, len) {
|
|
|
7
7
|
function _array_with_holes(arr) {
|
|
8
8
|
if (Array.isArray(arr)) return arr;
|
|
9
9
|
}
|
|
10
|
+
function _array_without_holes(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
+
}
|
|
10
13
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
14
|
try {
|
|
12
15
|
var info = gen[key](arg);
|
|
@@ -49,6 +52,9 @@ function _define_property(obj, key, value) {
|
|
|
49
52
|
}
|
|
50
53
|
return obj;
|
|
51
54
|
}
|
|
55
|
+
function _iterable_to_array(iter) {
|
|
56
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
57
|
+
}
|
|
52
58
|
function _iterable_to_array_limit(arr, i) {
|
|
53
59
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
54
60
|
if (_i == null) return;
|
|
@@ -76,6 +82,9 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
76
82
|
function _non_iterable_rest() {
|
|
77
83
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
78
84
|
}
|
|
85
|
+
function _non_iterable_spread() {
|
|
86
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
87
|
+
}
|
|
79
88
|
function _object_spread(target) {
|
|
80
89
|
for(var i = 1; i < arguments.length; i++){
|
|
81
90
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -118,6 +127,9 @@ function _object_spread_props(target, source) {
|
|
|
118
127
|
function _sliced_to_array(arr, i) {
|
|
119
128
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
120
129
|
}
|
|
130
|
+
function _to_consumable_array(arr) {
|
|
131
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
132
|
+
}
|
|
121
133
|
function _type_of(obj) {
|
|
122
134
|
"@swc/helpers - typeof";
|
|
123
135
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -285,6 +297,9 @@ __export(src_exports, {
|
|
|
285
297
|
AuthProvider: function() {
|
|
286
298
|
return app_default;
|
|
287
299
|
},
|
|
300
|
+
extractErrorMessages: function() {
|
|
301
|
+
return extractErrorMessages;
|
|
302
|
+
},
|
|
288
303
|
useActivate: function() {
|
|
289
304
|
return useActivate_default;
|
|
290
305
|
},
|
|
@@ -1096,6 +1111,9 @@ var useLogin = function(initialFields, apiUrl) {
|
|
|
1096
1111
|
var status = (0, import_react_redux2.useSelector)(function(state) {
|
|
1097
1112
|
return state.auth.status;
|
|
1098
1113
|
});
|
|
1114
|
+
var currentUser = (0, import_react_redux2.useSelector)(function(state) {
|
|
1115
|
+
return state.auth.user;
|
|
1116
|
+
});
|
|
1099
1117
|
var isStatus200 = status === 200;
|
|
1100
1118
|
(0, import_react2.useEffect)(function() {
|
|
1101
1119
|
return function() {
|
|
@@ -1167,7 +1185,8 @@ var useLogin = function(initialFields, apiUrl) {
|
|
|
1167
1185
|
onChange: handleChange,
|
|
1168
1186
|
onSubmit: handleSubmit,
|
|
1169
1187
|
isAuthenticated: isAuthenticated,
|
|
1170
|
-
isStatus200: isStatus200
|
|
1188
|
+
isStatus200: isStatus200,
|
|
1189
|
+
currentUser: currentUser
|
|
1171
1190
|
};
|
|
1172
1191
|
};
|
|
1173
1192
|
var useLogin_default = useLogin;
|
|
@@ -1996,9 +2015,35 @@ var AuthProvider = function(param) {
|
|
|
1996
2015
|
}, children);
|
|
1997
2016
|
};
|
|
1998
2017
|
var app_default = AuthProvider;
|
|
2018
|
+
// src/utils/ExtractErrorMsg.tsx
|
|
2019
|
+
var extractErrorMessages = function(errorMsg) {
|
|
2020
|
+
if (typeof errorMsg === "string") {
|
|
2021
|
+
return [
|
|
2022
|
+
errorMsg
|
|
2023
|
+
];
|
|
2024
|
+
}
|
|
2025
|
+
if (Array.isArray(errorMsg)) {
|
|
2026
|
+
return errorMsg;
|
|
2027
|
+
}
|
|
2028
|
+
if ((typeof errorMsg === "undefined" ? "undefined" : _type_of(errorMsg)) === "object" && errorMsg !== null) {
|
|
2029
|
+
var extractedMessages = [];
|
|
2030
|
+
Object.keys(errorMsg).forEach(function(key) {
|
|
2031
|
+
var value = errorMsg[key];
|
|
2032
|
+
if (Array.isArray(value)) {
|
|
2033
|
+
var _extractedMessages;
|
|
2034
|
+
(_extractedMessages = extractedMessages).push.apply(_extractedMessages, _to_consumable_array(value));
|
|
2035
|
+
} else if (typeof value === "string") {
|
|
2036
|
+
extractedMessages.push(value);
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
return extractedMessages;
|
|
2040
|
+
}
|
|
2041
|
+
return [];
|
|
2042
|
+
};
|
|
1999
2043
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2000
2044
|
0 && (module.exports = {
|
|
2001
2045
|
AuthProvider: AuthProvider,
|
|
2046
|
+
extractErrorMessages: extractErrorMessages,
|
|
2002
2047
|
useActivate: useActivate,
|
|
2003
2048
|
useAuthicatedUser: useAuthicatedUser,
|
|
2004
2049
|
useChangeAuthenticatedUserPassword: useChangeAuthenticatedUserPassword,
|
package/dist/index.mjs
CHANGED
|
@@ -358,6 +358,7 @@ var useLogin = (initialFields, apiUrl) => {
|
|
|
358
358
|
);
|
|
359
359
|
const error = useSelector2((state) => state.auth.error);
|
|
360
360
|
const status = useSelector2((state) => state.auth.status);
|
|
361
|
+
const currentUser = useSelector2((state) => state.auth.user);
|
|
361
362
|
const isStatus200 = status === 200;
|
|
362
363
|
useEffect2(() => {
|
|
363
364
|
return () => {
|
|
@@ -389,7 +390,8 @@ var useLogin = (initialFields, apiUrl) => {
|
|
|
389
390
|
onChange: handleChange,
|
|
390
391
|
onSubmit: handleSubmit,
|
|
391
392
|
isAuthenticated,
|
|
392
|
-
isStatus200
|
|
393
|
+
isStatus200,
|
|
394
|
+
currentUser
|
|
393
395
|
};
|
|
394
396
|
};
|
|
395
397
|
var useLogin_default = useLogin;
|
|
@@ -871,8 +873,32 @@ var AuthProvider = ({ children }) => {
|
|
|
871
873
|
return /* @__PURE__ */ React.createElement(Provider, { store: store_default }, children);
|
|
872
874
|
};
|
|
873
875
|
var app_default = AuthProvider;
|
|
876
|
+
|
|
877
|
+
// src/utils/ExtractErrorMsg.tsx
|
|
878
|
+
var extractErrorMessages = (errorMsg) => {
|
|
879
|
+
if (typeof errorMsg === "string") {
|
|
880
|
+
return [errorMsg];
|
|
881
|
+
}
|
|
882
|
+
if (Array.isArray(errorMsg)) {
|
|
883
|
+
return errorMsg;
|
|
884
|
+
}
|
|
885
|
+
if (typeof errorMsg === "object" && errorMsg !== null) {
|
|
886
|
+
const extractedMessages = [];
|
|
887
|
+
Object.keys(errorMsg).forEach((key) => {
|
|
888
|
+
const value = errorMsg[key];
|
|
889
|
+
if (Array.isArray(value)) {
|
|
890
|
+
extractedMessages.push(...value);
|
|
891
|
+
} else if (typeof value === "string") {
|
|
892
|
+
extractedMessages.push(value);
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
return extractedMessages;
|
|
896
|
+
}
|
|
897
|
+
return [];
|
|
898
|
+
};
|
|
874
899
|
export {
|
|
875
900
|
app_default as AuthProvider,
|
|
901
|
+
extractErrorMessages,
|
|
876
902
|
useActivate_default as useActivate,
|
|
877
903
|
useLoadUser_default as useAuthicatedUser,
|
|
878
904
|
useChangePassword_default as useChangeAuthenticatedUserPassword,
|