@stokr/components-library 2.0.0-beta.30 → 2.0.0-beta.31
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/context/AuthContext.js +9 -10
- package/package.json +1 -1
|
@@ -48,11 +48,10 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
48
48
|
}
|
|
49
49
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
50
50
|
_defineProperty(_assertThisInitialized(_this), "userRef", /*#__PURE__*/_react.default.createRef(null));
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "isGettingUserRef", /*#__PURE__*/_react.default.createRef(false));
|
|
52
51
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
53
52
|
user: undefined,
|
|
54
53
|
firebaseUser: undefined,
|
|
55
|
-
isFetchingUser:
|
|
54
|
+
isFetchingUser: false,
|
|
56
55
|
avatar: _avatarPlaceholder.default,
|
|
57
56
|
userMfaEnrollment: null,
|
|
58
57
|
waitingFor2fa: false,
|
|
@@ -393,7 +392,9 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
393
392
|
});
|
|
394
393
|
return _context8.abrupt("return");
|
|
395
394
|
case 4:
|
|
396
|
-
_this.
|
|
395
|
+
_this.setState({
|
|
396
|
+
isFetchingUser: true
|
|
397
|
+
});
|
|
397
398
|
_axios.default.defaults.headers.common.Authorization = "Bearer ".concat(accessToken);
|
|
398
399
|
console.log('🚀 ~ Im in get user:');
|
|
399
400
|
//pass this function as a prop if you need any custom logic after user/get
|
|
@@ -432,27 +433,25 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
432
433
|
_this.setState({
|
|
433
434
|
isFetchingUser: false
|
|
434
435
|
});
|
|
435
|
-
_this.isGettingUserRef.current = false;
|
|
436
436
|
|
|
437
437
|
//redirect to home if user is on login or signup route (affects homepage only)
|
|
438
438
|
_this.replaceLocationPathName();
|
|
439
439
|
|
|
440
440
|
//if you need user info immediately after call (before setState is executed), you can use this
|
|
441
441
|
return _context8.abrupt("return", user);
|
|
442
|
-
case
|
|
443
|
-
_context8.prev =
|
|
442
|
+
case 33:
|
|
443
|
+
_context8.prev = 33;
|
|
444
444
|
_context8.t0 = _context8["catch"](8);
|
|
445
445
|
_this.setState({
|
|
446
446
|
isFetchingUser: false
|
|
447
447
|
});
|
|
448
|
-
_this.isGettingUserRef.current = false;
|
|
449
448
|
console.log("Error in getUser: ".concat(_context8.t0));
|
|
450
449
|
throw _context8.t0;
|
|
451
|
-
case
|
|
450
|
+
case 38:
|
|
452
451
|
case "end":
|
|
453
452
|
return _context8.stop();
|
|
454
453
|
}
|
|
455
|
-
}, _callee8, null, [[8,
|
|
454
|
+
}, _callee8, null, [[8, 33]]);
|
|
456
455
|
})));
|
|
457
456
|
_defineProperty(_assertThisInitialized(_this), "checkUserPhoto", function (avatar) {
|
|
458
457
|
try {
|
|
@@ -960,7 +959,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
960
959
|
var isActivatingUser = window.location.href.includes('verifyEmail');
|
|
961
960
|
if (isActivatingUser) {
|
|
962
961
|
this.handleVerifyEmail();
|
|
963
|
-
} else if (this.
|
|
962
|
+
} else if (this.state.isFetchingUser === false) {
|
|
964
963
|
//only call getUser if we are not already calling it from another component
|
|
965
964
|
this.getUser();
|
|
966
965
|
}
|