react-redux-django-auth 1.3.8 → 1.4.0
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 +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +7 -114
- package/dist/index.mjs +22 -47
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1300,7 +1300,6 @@ 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), isLoading = _ref[0], setIsLoading = _ref[1];
|
|
1304
1303
|
var isAuthenticated = (0, import_react_redux5.useSelector)(function(state) {
|
|
1305
1304
|
return state.auth.isAuthenticated;
|
|
1306
1305
|
});
|
|
@@ -1311,76 +1310,15 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1311
1310
|
return state.auth.user;
|
|
1312
1311
|
});
|
|
1313
1312
|
(0, import_react5.useEffect)(function() {
|
|
1314
|
-
|
|
1315
|
-
return _async_to_generator(function() {
|
|
1316
|
-
return _ts_generator(this, function(_state) {
|
|
1317
|
-
switch(_state.label){
|
|
1318
|
-
case 0:
|
|
1319
|
-
setIsLoading(true);
|
|
1320
|
-
_state.label = 1;
|
|
1321
|
-
case 1:
|
|
1322
|
-
_state.trys.push([
|
|
1323
|
-
1,
|
|
1324
|
-
,
|
|
1325
|
-
3,
|
|
1326
|
-
4
|
|
1327
|
-
]);
|
|
1328
|
-
return [
|
|
1329
|
-
4,
|
|
1330
|
-
dispatch(checkAuthenticated(apiURL))
|
|
1331
|
-
];
|
|
1332
|
-
case 2:
|
|
1333
|
-
_state.sent();
|
|
1334
|
-
return [
|
|
1335
|
-
3,
|
|
1336
|
-
4
|
|
1337
|
-
];
|
|
1338
|
-
case 3:
|
|
1339
|
-
return [
|
|
1340
|
-
7
|
|
1341
|
-
];
|
|
1342
|
-
case 4:
|
|
1343
|
-
return [
|
|
1344
|
-
2
|
|
1345
|
-
];
|
|
1346
|
-
}
|
|
1347
|
-
});
|
|
1348
|
-
})();
|
|
1349
|
-
};
|
|
1350
|
-
fetchAuthData();
|
|
1313
|
+
dispatch(checkAuthenticated(apiURL));
|
|
1351
1314
|
}, [
|
|
1352
1315
|
dispatch,
|
|
1353
1316
|
apiURL,
|
|
1354
1317
|
location
|
|
1355
1318
|
]);
|
|
1356
1319
|
(0, import_react5.useEffect)(function() {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
return _ts_generator(this, function(_state) {
|
|
1360
|
-
switch(_state.label){
|
|
1361
|
-
case 0:
|
|
1362
|
-
if (!isAuthenticated) return [
|
|
1363
|
-
3,
|
|
1364
|
-
2
|
|
1365
|
-
];
|
|
1366
|
-
return [
|
|
1367
|
-
4,
|
|
1368
|
-
dispatch(load_user(apiURL))
|
|
1369
|
-
];
|
|
1370
|
-
case 1:
|
|
1371
|
-
_state.sent();
|
|
1372
|
-
_state.label = 2;
|
|
1373
|
-
case 2:
|
|
1374
|
-
setIsLoading(false);
|
|
1375
|
-
return [
|
|
1376
|
-
2
|
|
1377
|
-
];
|
|
1378
|
-
}
|
|
1379
|
-
});
|
|
1380
|
-
})();
|
|
1381
|
-
};
|
|
1382
|
-
if (isAuthenticated !== null) {
|
|
1383
|
-
fetchUserData();
|
|
1320
|
+
if (isAuthenticated) {
|
|
1321
|
+
dispatch(load_user(apiURL));
|
|
1384
1322
|
}
|
|
1385
1323
|
}, [
|
|
1386
1324
|
dispatch,
|
|
@@ -1388,27 +1326,7 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1388
1326
|
apiURL
|
|
1389
1327
|
]);
|
|
1390
1328
|
var refreshUser = (0, import_react5.useCallback)(function() {
|
|
1391
|
-
|
|
1392
|
-
var loadAndFinish = function() {
|
|
1393
|
-
return _async_to_generator(function() {
|
|
1394
|
-
return _ts_generator(this, function(_state) {
|
|
1395
|
-
switch(_state.label){
|
|
1396
|
-
case 0:
|
|
1397
|
-
return [
|
|
1398
|
-
4,
|
|
1399
|
-
dispatch(load_user(apiURL))
|
|
1400
|
-
];
|
|
1401
|
-
case 1:
|
|
1402
|
-
_state.sent();
|
|
1403
|
-
setIsLoading(false);
|
|
1404
|
-
return [
|
|
1405
|
-
2
|
|
1406
|
-
];
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
})();
|
|
1410
|
-
};
|
|
1411
|
-
loadAndFinish();
|
|
1329
|
+
dispatch(load_user(apiURL));
|
|
1412
1330
|
}, [
|
|
1413
1331
|
dispatch,
|
|
1414
1332
|
apiURL
|
|
@@ -1418,37 +1336,13 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1418
1336
|
return _ts_generator(this, function(_state) {
|
|
1419
1337
|
switch(_state.label){
|
|
1420
1338
|
case 0:
|
|
1421
|
-
setIsLoading(true);
|
|
1422
|
-
_state.label = 1;
|
|
1423
|
-
case 1:
|
|
1424
|
-
_state.trys.push([
|
|
1425
|
-
1,
|
|
1426
|
-
,
|
|
1427
|
-
4,
|
|
1428
|
-
5
|
|
1429
|
-
]);
|
|
1430
1339
|
return [
|
|
1431
1340
|
4,
|
|
1432
1341
|
dispatch(checkAuthenticated(apiURL))
|
|
1433
1342
|
];
|
|
1434
|
-
case
|
|
1435
|
-
_state.sent();
|
|
1436
|
-
return [
|
|
1437
|
-
4,
|
|
1438
|
-
dispatch(load_user(apiURL))
|
|
1439
|
-
];
|
|
1440
|
-
case 3:
|
|
1343
|
+
case 1:
|
|
1441
1344
|
_state.sent();
|
|
1442
|
-
|
|
1443
|
-
3,
|
|
1444
|
-
5
|
|
1445
|
-
];
|
|
1446
|
-
case 4:
|
|
1447
|
-
setIsLoading(false);
|
|
1448
|
-
return [
|
|
1449
|
-
7
|
|
1450
|
-
];
|
|
1451
|
-
case 5:
|
|
1345
|
+
dispatch(load_user(apiURL));
|
|
1452
1346
|
return [
|
|
1453
1347
|
2
|
|
1454
1348
|
];
|
|
@@ -1470,8 +1364,7 @@ var useAuthicatedUser = function(apiURL, location) {
|
|
|
1470
1364
|
currentUser: currentUser,
|
|
1471
1365
|
clearErrors: clearErrorsWrapper,
|
|
1472
1366
|
refreshUser: refreshUser,
|
|
1473
|
-
refreshAuth: refreshAuth
|
|
1474
|
-
isLoading: isLoading
|
|
1367
|
+
refreshAuth: refreshAuth
|
|
1475
1368
|
};
|
|
1476
1369
|
};
|
|
1477
1370
|
var useLoadUser_default = useAuthicatedUser;
|
package/dist/index.mjs
CHANGED
|
@@ -458,53 +458,29 @@ 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
|
|
461
|
+
import { useCallback as useCallback5, useEffect as useEffect4 } 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 [isLoading, setIsLoading] = useState4(true);
|
|
466
465
|
const isAuthenticated = useSelector4(
|
|
467
466
|
(state) => state.auth.isAuthenticated
|
|
468
467
|
);
|
|
469
468
|
const error = useSelector4((state) => state.auth.error);
|
|
470
469
|
const currentUser = useSelector4((state) => state.auth.user);
|
|
471
470
|
useEffect4(() => {
|
|
472
|
-
|
|
473
|
-
setIsLoading(true);
|
|
474
|
-
try {
|
|
475
|
-
await dispatch(checkAuthenticated(apiURL));
|
|
476
|
-
} finally {
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
fetchAuthData();
|
|
471
|
+
dispatch(checkAuthenticated(apiURL));
|
|
480
472
|
}, [dispatch, apiURL, location]);
|
|
481
473
|
useEffect4(() => {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
await dispatch(load_user(apiURL));
|
|
485
|
-
}
|
|
486
|
-
setIsLoading(false);
|
|
487
|
-
};
|
|
488
|
-
if (isAuthenticated !== null) {
|
|
489
|
-
fetchUserData();
|
|
474
|
+
if (isAuthenticated) {
|
|
475
|
+
dispatch(load_user(apiURL));
|
|
490
476
|
}
|
|
491
477
|
}, [dispatch, isAuthenticated, apiURL]);
|
|
492
478
|
const refreshUser = useCallback5(() => {
|
|
493
|
-
|
|
494
|
-
const loadAndFinish = async () => {
|
|
495
|
-
await dispatch(load_user(apiURL));
|
|
496
|
-
setIsLoading(false);
|
|
497
|
-
};
|
|
498
|
-
loadAndFinish();
|
|
479
|
+
dispatch(load_user(apiURL));
|
|
499
480
|
}, [dispatch, apiURL]);
|
|
500
481
|
const refreshAuth = useCallback5(async () => {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
await dispatch(checkAuthenticated(apiURL));
|
|
504
|
-
await dispatch(load_user(apiURL));
|
|
505
|
-
} finally {
|
|
506
|
-
setIsLoading(false);
|
|
507
|
-
}
|
|
482
|
+
await dispatch(checkAuthenticated(apiURL));
|
|
483
|
+
dispatch(load_user(apiURL));
|
|
508
484
|
}, [dispatch, apiURL]);
|
|
509
485
|
const clearErrorsWrapper = useCallback5(() => {
|
|
510
486
|
dispatch(clearErrors());
|
|
@@ -515,19 +491,18 @@ var useAuthicatedUser = (apiURL, location) => {
|
|
|
515
491
|
currentUser,
|
|
516
492
|
clearErrors: clearErrorsWrapper,
|
|
517
493
|
refreshUser,
|
|
518
|
-
refreshAuth
|
|
519
|
-
isLoading
|
|
494
|
+
refreshAuth
|
|
520
495
|
};
|
|
521
496
|
};
|
|
522
497
|
var useLoadUser_default = useAuthicatedUser;
|
|
523
498
|
|
|
524
499
|
// src/hooks/useResetPassword.tsx
|
|
525
|
-
import { useState as
|
|
500
|
+
import { useState as useState4, useCallback as useCallback6, useEffect as useEffect5 } from "react";
|
|
526
501
|
import { useDispatch as useDispatch6, useSelector as useSelector5 } from "react-redux";
|
|
527
502
|
var useResetPassword = (apiUrl) => {
|
|
528
503
|
const dispatch = useDispatch6();
|
|
529
|
-
const [loading, setLoading] =
|
|
530
|
-
const [email, setEmail] =
|
|
504
|
+
const [loading, setLoading] = useState4(false);
|
|
505
|
+
const [email, setEmail] = useState4("");
|
|
531
506
|
const status = useSelector5((state) => state.auth.status);
|
|
532
507
|
const error = useSelector5((state) => state.auth.error);
|
|
533
508
|
const isStatus204 = status === 204;
|
|
@@ -566,12 +541,12 @@ var useResetPassword = (apiUrl) => {
|
|
|
566
541
|
var useResetPassword_default = useResetPassword;
|
|
567
542
|
|
|
568
543
|
// src/hooks/usePasswordConfirm.tsx
|
|
569
|
-
import { useState as
|
|
544
|
+
import { useState as useState5, useCallback as useCallback7, useEffect as useEffect6 } from "react";
|
|
570
545
|
import { useDispatch as useDispatch7, useSelector as useSelector6 } from "react-redux";
|
|
571
546
|
var usePasswordConfirm = (initialFields, apiUrl) => {
|
|
572
547
|
const dispatch = useDispatch7();
|
|
573
|
-
const [loading, setLoading] =
|
|
574
|
-
const [formData, setFormData] =
|
|
548
|
+
const [loading, setLoading] = useState5(false);
|
|
549
|
+
const [formData, setFormData] = useState5(initialFields);
|
|
575
550
|
const error = useSelector6((state) => state.auth.error);
|
|
576
551
|
const status = useSelector6((state) => state.auth.status);
|
|
577
552
|
const isStatus204 = status === 204;
|
|
@@ -611,13 +586,13 @@ var usePasswordConfirm = (initialFields, apiUrl) => {
|
|
|
611
586
|
var usePasswordConfirm_default = usePasswordConfirm;
|
|
612
587
|
|
|
613
588
|
// src/hooks/useChangePassword.tsx
|
|
614
|
-
import { useState as
|
|
589
|
+
import { useState as useState6, useCallback as useCallback8, useEffect as useEffect7 } from "react";
|
|
615
590
|
import { useDispatch as useDispatch8, useSelector as useSelector7 } from "react-redux";
|
|
616
591
|
var useChangeAuthenticatedUserPassword = (initialFields, apiUrl) => {
|
|
617
592
|
const dispatch = useDispatch8();
|
|
618
|
-
const [loading, setLoading] =
|
|
619
|
-
const [formData, setFormData] =
|
|
620
|
-
const [error, setError] =
|
|
593
|
+
const [loading, setLoading] = useState6(false);
|
|
594
|
+
const [formData, setFormData] = useState6(initialFields);
|
|
595
|
+
const [error, setError] = useState6(null);
|
|
621
596
|
const authError = useSelector7((state) => state.auth.error);
|
|
622
597
|
const status = useSelector7((state) => state.auth.status);
|
|
623
598
|
useEffect7(() => {
|
|
@@ -662,7 +637,7 @@ var useChangePassword_default = useChangeAuthenticatedUserPassword;
|
|
|
662
637
|
|
|
663
638
|
// src/hooks/useGoogleAuth.tsx
|
|
664
639
|
import { useDispatch as useDispatch9, useSelector as useSelector8 } from "react-redux";
|
|
665
|
-
import { useEffect as useEffect8, useCallback as useCallback9, useState as
|
|
640
|
+
import { useEffect as useEffect8, useCallback as useCallback9, useState as useState7 } from "react";
|
|
666
641
|
import axios2 from "axios";
|
|
667
642
|
var useGoogleAuth = (apiUrl) => {
|
|
668
643
|
const dispatch = useDispatch9();
|
|
@@ -671,7 +646,7 @@ var useGoogleAuth = (apiUrl) => {
|
|
|
671
646
|
);
|
|
672
647
|
const error = useSelector8((state) => state.auth.error);
|
|
673
648
|
const status = useSelector8((state) => state.auth.status);
|
|
674
|
-
const [loading, setLoading] =
|
|
649
|
+
const [loading, setLoading] = useState7(false);
|
|
675
650
|
const isStatus201 = status === 201;
|
|
676
651
|
const continueWithGoogle = useCallback9(async () => {
|
|
677
652
|
setLoading(true);
|
|
@@ -720,7 +695,7 @@ var useGoogleAuth_default = useGoogleAuth;
|
|
|
720
695
|
|
|
721
696
|
// src/hooks/useFacebookAuth.tsx
|
|
722
697
|
import { useDispatch as useDispatch10, useSelector as useSelector9 } from "react-redux";
|
|
723
|
-
import { useEffect as useEffect9, useCallback as useCallback10, useState as
|
|
698
|
+
import { useEffect as useEffect9, useCallback as useCallback10, useState as useState8 } from "react";
|
|
724
699
|
import axios3 from "axios";
|
|
725
700
|
var useFacebookAuth = (apiUrl) => {
|
|
726
701
|
const dispatch = useDispatch10();
|
|
@@ -729,7 +704,7 @@ var useFacebookAuth = (apiUrl) => {
|
|
|
729
704
|
);
|
|
730
705
|
const error = useSelector9((state) => state.auth.error);
|
|
731
706
|
const status = useSelector9((state) => state.auth.status);
|
|
732
|
-
const [loading, setLoading] =
|
|
707
|
+
const [loading, setLoading] = useState8(false);
|
|
733
708
|
const isStatus201 = status === 201;
|
|
734
709
|
const continueWithFacebook = useCallback10(async () => {
|
|
735
710
|
setLoading(true);
|