react-redux-django-auth 1.3.7 → 1.3.9
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +72 -7
- package/dist/index.mjs +41 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1300,6 +1300,8 @@ var import_react5 = require("react");
|
|
|
1300
1300
|
var import_react_redux5 = require("react-redux");
|
|
1301
1301
|
var useAuthicatedUser = function(apiURL, location) {
|
|
1302
1302
|
var dispatch = (0, import_react_redux5.useDispatch)();
|
|
1303
|
+
var _ref = _sliced_to_array((0, import_react5.useState)(true), 2), isAuthLoading = _ref[0], setIsAuthLoading = _ref[1];
|
|
1304
|
+
var _ref1 = _sliced_to_array((0, import_react5.useState)(false), 2), isUserLoading = _ref1[0], setIsUserLoading = _ref1[1];
|
|
1303
1305
|
var isAuthenticated = (0, import_react_redux5.useSelector)(function(state) {
|
|
1304
1306
|
return state.auth.isAuthenticated;
|
|
1305
1307
|
});
|
|
@@ -1310,7 +1312,27 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1310
1312
|
return state.auth.user;
|
|
1311
1313
|
});
|
|
1312
1314
|
(0, import_react5.useEffect)(function() {
|
|
1313
|
-
|
|
1315
|
+
var runAuthCheck = function() {
|
|
1316
|
+
return _async_to_generator(function() {
|
|
1317
|
+
return _ts_generator(this, function(_state) {
|
|
1318
|
+
switch(_state.label){
|
|
1319
|
+
case 0:
|
|
1320
|
+
setIsAuthLoading(true);
|
|
1321
|
+
return [
|
|
1322
|
+
4,
|
|
1323
|
+
dispatch(checkAuthenticated(apiURL))
|
|
1324
|
+
];
|
|
1325
|
+
case 1:
|
|
1326
|
+
_state.sent();
|
|
1327
|
+
setIsAuthLoading(false);
|
|
1328
|
+
return [
|
|
1329
|
+
2
|
|
1330
|
+
];
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
})();
|
|
1334
|
+
};
|
|
1335
|
+
runAuthCheck();
|
|
1314
1336
|
}, [
|
|
1315
1337
|
dispatch,
|
|
1316
1338
|
apiURL,
|
|
@@ -1318,15 +1340,55 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1318
1340
|
]);
|
|
1319
1341
|
(0, import_react5.useEffect)(function() {
|
|
1320
1342
|
if (isAuthenticated) {
|
|
1321
|
-
|
|
1343
|
+
var loadUserData = function() {
|
|
1344
|
+
return _async_to_generator(function() {
|
|
1345
|
+
return _ts_generator(this, function(_state) {
|
|
1346
|
+
switch(_state.label){
|
|
1347
|
+
case 0:
|
|
1348
|
+
setIsUserLoading(true);
|
|
1349
|
+
return [
|
|
1350
|
+
4,
|
|
1351
|
+
dispatch(load_user(apiURL))
|
|
1352
|
+
];
|
|
1353
|
+
case 1:
|
|
1354
|
+
_state.sent();
|
|
1355
|
+
setIsUserLoading(false);
|
|
1356
|
+
return [
|
|
1357
|
+
2
|
|
1358
|
+
];
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
})();
|
|
1362
|
+
};
|
|
1363
|
+
loadUserData();
|
|
1322
1364
|
}
|
|
1323
1365
|
}, [
|
|
1324
1366
|
dispatch,
|
|
1325
|
-
|
|
1326
|
-
|
|
1367
|
+
apiURL,
|
|
1368
|
+
isAuthenticated
|
|
1327
1369
|
]);
|
|
1328
1370
|
var refreshUser = (0, import_react5.useCallback)(function() {
|
|
1329
|
-
|
|
1371
|
+
var loadAndFinish = function() {
|
|
1372
|
+
return _async_to_generator(function() {
|
|
1373
|
+
return _ts_generator(this, function(_state) {
|
|
1374
|
+
switch(_state.label){
|
|
1375
|
+
case 0:
|
|
1376
|
+
setIsUserLoading(true);
|
|
1377
|
+
return [
|
|
1378
|
+
4,
|
|
1379
|
+
dispatch(load_user(apiURL))
|
|
1380
|
+
];
|
|
1381
|
+
case 1:
|
|
1382
|
+
_state.sent();
|
|
1383
|
+
setIsUserLoading(false);
|
|
1384
|
+
return [
|
|
1385
|
+
2
|
|
1386
|
+
];
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
})();
|
|
1390
|
+
};
|
|
1391
|
+
loadAndFinish();
|
|
1330
1392
|
}, [
|
|
1331
1393
|
dispatch,
|
|
1332
1394
|
apiURL
|
|
@@ -1336,13 +1398,14 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1336
1398
|
return _ts_generator(this, function(_state) {
|
|
1337
1399
|
switch(_state.label){
|
|
1338
1400
|
case 0:
|
|
1401
|
+
setIsAuthLoading(true);
|
|
1339
1402
|
return [
|
|
1340
1403
|
4,
|
|
1341
1404
|
dispatch(checkAuthenticated(apiURL))
|
|
1342
1405
|
];
|
|
1343
1406
|
case 1:
|
|
1344
1407
|
_state.sent();
|
|
1345
|
-
|
|
1408
|
+
setIsAuthLoading(false);
|
|
1346
1409
|
return [
|
|
1347
1410
|
2
|
|
1348
1411
|
];
|
|
@@ -1358,13 +1421,15 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1358
1421
|
}, [
|
|
1359
1422
|
dispatch
|
|
1360
1423
|
]);
|
|
1424
|
+
var isLoading = isAuthLoading || isUserLoading;
|
|
1361
1425
|
return {
|
|
1362
1426
|
error: error,
|
|
1363
1427
|
isAuthenticated: isAuthenticated,
|
|
1364
1428
|
currentUser: currentUser,
|
|
1365
1429
|
clearErrors: clearErrorsWrapper,
|
|
1366
1430
|
refreshUser: refreshUser,
|
|
1367
|
-
refreshAuth: refreshAuth
|
|
1431
|
+
refreshAuth: refreshAuth,
|
|
1432
|
+
isLoading: isLoading
|
|
1368
1433
|
};
|
|
1369
1434
|
};
|
|
1370
1435
|
var useLoadUser_default = useAuthicatedUser;
|
package/dist/index.mjs
CHANGED
|
@@ -458,51 +458,71 @@ var useSignup = (initialFields, apiUrl) => {
|
|
|
458
458
|
var useSignup_default = useSignup;
|
|
459
459
|
|
|
460
460
|
// src/hooks/useLoadUser.tsx
|
|
461
|
-
import { useCallback as useCallback5, useEffect as useEffect4 } from "react";
|
|
461
|
+
import { useCallback as useCallback5, useEffect as useEffect4, useState as useState4 } from "react";
|
|
462
462
|
import { useDispatch as useDispatch5, useSelector as useSelector4 } from "react-redux";
|
|
463
463
|
var useAuthicatedUser = (apiURL, location) => {
|
|
464
464
|
const dispatch = useDispatch5();
|
|
465
|
+
const [isAuthLoading, setIsAuthLoading] = useState4(true);
|
|
466
|
+
const [isUserLoading, setIsUserLoading] = useState4(false);
|
|
465
467
|
const isAuthenticated = useSelector4(
|
|
466
468
|
(state) => state.auth.isAuthenticated
|
|
467
469
|
);
|
|
468
470
|
const error = useSelector4((state) => state.auth.error);
|
|
469
471
|
const currentUser = useSelector4((state) => state.auth.user);
|
|
470
472
|
useEffect4(() => {
|
|
471
|
-
|
|
473
|
+
const runAuthCheck = async () => {
|
|
474
|
+
setIsAuthLoading(true);
|
|
475
|
+
await dispatch(checkAuthenticated(apiURL));
|
|
476
|
+
setIsAuthLoading(false);
|
|
477
|
+
};
|
|
478
|
+
runAuthCheck();
|
|
472
479
|
}, [dispatch, apiURL, location]);
|
|
473
480
|
useEffect4(() => {
|
|
474
481
|
if (isAuthenticated) {
|
|
475
|
-
|
|
482
|
+
const loadUserData = async () => {
|
|
483
|
+
setIsUserLoading(true);
|
|
484
|
+
await dispatch(load_user(apiURL));
|
|
485
|
+
setIsUserLoading(false);
|
|
486
|
+
};
|
|
487
|
+
loadUserData();
|
|
476
488
|
}
|
|
477
|
-
}, [dispatch,
|
|
489
|
+
}, [dispatch, apiURL, isAuthenticated]);
|
|
478
490
|
const refreshUser = useCallback5(() => {
|
|
479
|
-
|
|
491
|
+
const loadAndFinish = async () => {
|
|
492
|
+
setIsUserLoading(true);
|
|
493
|
+
await dispatch(load_user(apiURL));
|
|
494
|
+
setIsUserLoading(false);
|
|
495
|
+
};
|
|
496
|
+
loadAndFinish();
|
|
480
497
|
}, [dispatch, apiURL]);
|
|
481
498
|
const refreshAuth = useCallback5(async () => {
|
|
499
|
+
setIsAuthLoading(true);
|
|
482
500
|
await dispatch(checkAuthenticated(apiURL));
|
|
483
|
-
|
|
501
|
+
setIsAuthLoading(false);
|
|
484
502
|
}, [dispatch, apiURL]);
|
|
485
503
|
const clearErrorsWrapper = useCallback5(() => {
|
|
486
504
|
dispatch(clearErrors());
|
|
487
505
|
}, [dispatch]);
|
|
506
|
+
const isLoading = isAuthLoading || isUserLoading;
|
|
488
507
|
return {
|
|
489
508
|
error,
|
|
490
509
|
isAuthenticated,
|
|
491
510
|
currentUser,
|
|
492
511
|
clearErrors: clearErrorsWrapper,
|
|
493
512
|
refreshUser,
|
|
494
|
-
refreshAuth
|
|
513
|
+
refreshAuth,
|
|
514
|
+
isLoading
|
|
495
515
|
};
|
|
496
516
|
};
|
|
497
517
|
var useLoadUser_default = useAuthicatedUser;
|
|
498
518
|
|
|
499
519
|
// src/hooks/useResetPassword.tsx
|
|
500
|
-
import { useState as
|
|
520
|
+
import { useState as useState5, useCallback as useCallback6, useEffect as useEffect5 } from "react";
|
|
501
521
|
import { useDispatch as useDispatch6, useSelector as useSelector5 } from "react-redux";
|
|
502
522
|
var useResetPassword = (apiUrl) => {
|
|
503
523
|
const dispatch = useDispatch6();
|
|
504
|
-
const [loading, setLoading] =
|
|
505
|
-
const [email, setEmail] =
|
|
524
|
+
const [loading, setLoading] = useState5(false);
|
|
525
|
+
const [email, setEmail] = useState5("");
|
|
506
526
|
const status = useSelector5((state) => state.auth.status);
|
|
507
527
|
const error = useSelector5((state) => state.auth.error);
|
|
508
528
|
const isStatus204 = status === 204;
|
|
@@ -541,12 +561,12 @@ var useResetPassword = (apiUrl) => {
|
|
|
541
561
|
var useResetPassword_default = useResetPassword;
|
|
542
562
|
|
|
543
563
|
// src/hooks/usePasswordConfirm.tsx
|
|
544
|
-
import { useState as
|
|
564
|
+
import { useState as useState6, useCallback as useCallback7, useEffect as useEffect6 } from "react";
|
|
545
565
|
import { useDispatch as useDispatch7, useSelector as useSelector6 } from "react-redux";
|
|
546
566
|
var usePasswordConfirm = (initialFields, apiUrl) => {
|
|
547
567
|
const dispatch = useDispatch7();
|
|
548
|
-
const [loading, setLoading] =
|
|
549
|
-
const [formData, setFormData] =
|
|
568
|
+
const [loading, setLoading] = useState6(false);
|
|
569
|
+
const [formData, setFormData] = useState6(initialFields);
|
|
550
570
|
const error = useSelector6((state) => state.auth.error);
|
|
551
571
|
const status = useSelector6((state) => state.auth.status);
|
|
552
572
|
const isStatus204 = status === 204;
|
|
@@ -586,13 +606,13 @@ var usePasswordConfirm = (initialFields, apiUrl) => {
|
|
|
586
606
|
var usePasswordConfirm_default = usePasswordConfirm;
|
|
587
607
|
|
|
588
608
|
// src/hooks/useChangePassword.tsx
|
|
589
|
-
import { useState as
|
|
609
|
+
import { useState as useState7, useCallback as useCallback8, useEffect as useEffect7 } from "react";
|
|
590
610
|
import { useDispatch as useDispatch8, useSelector as useSelector7 } from "react-redux";
|
|
591
611
|
var useChangeAuthenticatedUserPassword = (initialFields, apiUrl) => {
|
|
592
612
|
const dispatch = useDispatch8();
|
|
593
|
-
const [loading, setLoading] =
|
|
594
|
-
const [formData, setFormData] =
|
|
595
|
-
const [error, setError] =
|
|
613
|
+
const [loading, setLoading] = useState7(false);
|
|
614
|
+
const [formData, setFormData] = useState7(initialFields);
|
|
615
|
+
const [error, setError] = useState7(null);
|
|
596
616
|
const authError = useSelector7((state) => state.auth.error);
|
|
597
617
|
const status = useSelector7((state) => state.auth.status);
|
|
598
618
|
useEffect7(() => {
|
|
@@ -637,7 +657,7 @@ var useChangePassword_default = useChangeAuthenticatedUserPassword;
|
|
|
637
657
|
|
|
638
658
|
// src/hooks/useGoogleAuth.tsx
|
|
639
659
|
import { useDispatch as useDispatch9, useSelector as useSelector8 } from "react-redux";
|
|
640
|
-
import { useEffect as useEffect8, useCallback as useCallback9, useState as
|
|
660
|
+
import { useEffect as useEffect8, useCallback as useCallback9, useState as useState8 } from "react";
|
|
641
661
|
import axios2 from "axios";
|
|
642
662
|
var useGoogleAuth = (apiUrl) => {
|
|
643
663
|
const dispatch = useDispatch9();
|
|
@@ -646,7 +666,7 @@ var useGoogleAuth = (apiUrl) => {
|
|
|
646
666
|
);
|
|
647
667
|
const error = useSelector8((state) => state.auth.error);
|
|
648
668
|
const status = useSelector8((state) => state.auth.status);
|
|
649
|
-
const [loading, setLoading] =
|
|
669
|
+
const [loading, setLoading] = useState8(false);
|
|
650
670
|
const isStatus201 = status === 201;
|
|
651
671
|
const continueWithGoogle = useCallback9(async () => {
|
|
652
672
|
setLoading(true);
|
|
@@ -695,7 +715,7 @@ var useGoogleAuth_default = useGoogleAuth;
|
|
|
695
715
|
|
|
696
716
|
// src/hooks/useFacebookAuth.tsx
|
|
697
717
|
import { useDispatch as useDispatch10, useSelector as useSelector9 } from "react-redux";
|
|
698
|
-
import { useEffect as useEffect9, useCallback as useCallback10, useState as
|
|
718
|
+
import { useEffect as useEffect9, useCallback as useCallback10, useState as useState9 } from "react";
|
|
699
719
|
import axios3 from "axios";
|
|
700
720
|
var useFacebookAuth = (apiUrl) => {
|
|
701
721
|
const dispatch = useDispatch10();
|
|
@@ -704,7 +724,7 @@ var useFacebookAuth = (apiUrl) => {
|
|
|
704
724
|
);
|
|
705
725
|
const error = useSelector9((state) => state.auth.error);
|
|
706
726
|
const status = useSelector9((state) => state.auth.status);
|
|
707
|
-
const [loading, setLoading] =
|
|
727
|
+
const [loading, setLoading] = useState9(false);
|
|
708
728
|
const isStatus201 = status === 201;
|
|
709
729
|
const continueWithFacebook = useCallback10(async () => {
|
|
710
730
|
setLoading(true);
|