@stokr/components-library 1.1.8-beta.4 → 1.1.8-beta.6
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/components/headerHo/HeaderHo.js +15 -9
- package/dist/context/Auth.js +34 -1
- package/dist/context/AuthContext.js +100 -37
- package/package.json +1 -1
|
@@ -259,7 +259,9 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
|
|
|
259
259
|
activateMenu = _this$props3.activateMenu,
|
|
260
260
|
activeMenu = _this$props3.activeMenu,
|
|
261
261
|
withoutLoginSignupButton = _this$props3.withoutLoginSignupButton,
|
|
262
|
-
useRelativePathForMenu = _this$props3.useRelativePathForMenu
|
|
262
|
+
useRelativePathForMenu = _this$props3.useRelativePathForMenu,
|
|
263
|
+
isLoginModalOpen = _this$props3.isLoginModalOpen,
|
|
264
|
+
setIsLoginModalOpen = _this$props3.setIsLoginModalOpen;
|
|
263
265
|
var _this$context2 = this.context,
|
|
264
266
|
getUser = _this$context2.getUser,
|
|
265
267
|
_this$context2$user = _this$context2.user,
|
|
@@ -290,19 +292,22 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
|
|
|
290
292
|
}), /*#__PURE__*/_react.default.createElement(_LoginModal.default, {
|
|
291
293
|
isActionLoading: isActionLoading,
|
|
292
294
|
popupError: this.state.popupError,
|
|
293
|
-
isModalOpen: isModalOpen.login,
|
|
295
|
+
isModalOpen: isModalOpen.login || isLoginModalOpen,
|
|
294
296
|
onModalClose: function onModalClose() {
|
|
295
297
|
_this2.setOpenModalStatus('login', false);
|
|
298
|
+
setIsLoginModalOpen && setIsLoginModalOpen(false);
|
|
296
299
|
_this2.clearPopupError();
|
|
297
300
|
_this2.setIsActionLoading(undefined);
|
|
298
301
|
},
|
|
299
302
|
onModalSwitch: function onModalSwitch() {
|
|
300
303
|
_this2.switchOpenModal('login', 'signUp');
|
|
304
|
+
setIsLoginModalOpen && setIsLoginModalOpen(false);
|
|
301
305
|
_this2.clearPopupError();
|
|
302
306
|
_this2.setIsActionLoading(undefined);
|
|
303
307
|
},
|
|
304
308
|
onForgotPassword: function onForgotPassword() {
|
|
305
309
|
_this2.switchOpenModal('login', 'forgot');
|
|
310
|
+
setIsLoginModalOpen && setIsLoginModalOpen(false);
|
|
306
311
|
_this2.clearPopupError();
|
|
307
312
|
_this2.setIsActionLoading(undefined);
|
|
308
313
|
},
|
|
@@ -328,35 +333,36 @@ var HeaderHoClass = /*#__PURE__*/function (_Component) {
|
|
|
328
333
|
return loginUser(email, password);
|
|
329
334
|
case 10:
|
|
330
335
|
_this2.setOpenModalStatus('login', false);
|
|
336
|
+
setIsLoginModalOpen && setIsLoginModalOpen(false);
|
|
331
337
|
_this2.clearPopupError();
|
|
332
338
|
_this2.setIsActionLoading(undefined);
|
|
333
339
|
//await getUser()
|
|
334
|
-
_context.next =
|
|
340
|
+
_context.next = 26;
|
|
335
341
|
break;
|
|
336
|
-
case
|
|
337
|
-
_context.prev =
|
|
342
|
+
case 16:
|
|
343
|
+
_context.prev = 16;
|
|
338
344
|
_context.t0 = _context["catch"](3);
|
|
339
345
|
errorMessage = _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message; //handle switch modal correctly
|
|
340
346
|
if (!((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.code) === 'auth/multi-factor-auth-required')) {
|
|
341
|
-
_context.next =
|
|
347
|
+
_context.next = 24;
|
|
342
348
|
break;
|
|
343
349
|
}
|
|
344
350
|
_this2.switchOpenModal('login', 'enter2fa');
|
|
345
351
|
_this2.clearPopupError();
|
|
346
352
|
_this2.setIsActionLoading(undefined);
|
|
347
353
|
return _context.abrupt("return");
|
|
348
|
-
case
|
|
354
|
+
case 24:
|
|
349
355
|
if (errorMessage) {
|
|
350
356
|
_this2.setPopupError('login', errorMessage);
|
|
351
357
|
} else {
|
|
352
358
|
_this2.setPopupError('login', "Oops. Something's not right there. Try again?");
|
|
353
359
|
}
|
|
354
360
|
_this2.setIsActionLoading(undefined);
|
|
355
|
-
case
|
|
361
|
+
case 26:
|
|
356
362
|
case "end":
|
|
357
363
|
return _context.stop();
|
|
358
364
|
}
|
|
359
|
-
}, _callee, null, [[3,
|
|
365
|
+
}, _callee, null, [[3, 16]]);
|
|
360
366
|
}));
|
|
361
367
|
return function (_x) {
|
|
362
368
|
return _ref3.apply(this, arguments);
|
package/dist/context/Auth.js
CHANGED
|
@@ -99,6 +99,17 @@ var Auth = /*#__PURE__*/function () {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "requestUpdateEmail",
|
|
104
|
+
value: function requestUpdateEmail(data) {
|
|
105
|
+
return new Promise(function (resolve, reject) {
|
|
106
|
+
_axios.default.post("user/requestUpdateEmail", data).then(function (response) {
|
|
107
|
+
resolve(response.data);
|
|
108
|
+
}).catch(function (err) {
|
|
109
|
+
reject(err);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
102
113
|
}, {
|
|
103
114
|
key: "checkPrivateInvestor",
|
|
104
115
|
value: function checkPrivateInvestor(data) {
|
|
@@ -121,6 +132,17 @@ var Auth = /*#__PURE__*/function () {
|
|
|
121
132
|
});
|
|
122
133
|
});
|
|
123
134
|
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "fetchTrackingUserLastTime",
|
|
137
|
+
value: function fetchTrackingUserLastTime(data) {
|
|
138
|
+
return new Promise(function (resolve, reject) {
|
|
139
|
+
_axios.default.post("tracking-user/getLast", data).then(function (response) {
|
|
140
|
+
resolve(response.data);
|
|
141
|
+
}).catch(function (err) {
|
|
142
|
+
reject(err);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
124
146
|
}, {
|
|
125
147
|
key: "updateUser",
|
|
126
148
|
value: function updateUser(data) {
|
|
@@ -143,6 +165,17 @@ var Auth = /*#__PURE__*/function () {
|
|
|
143
165
|
});
|
|
144
166
|
});
|
|
145
167
|
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "createWallet",
|
|
170
|
+
value: function createWallet(data) {
|
|
171
|
+
return new Promise(function (resolve, reject) {
|
|
172
|
+
_axios.default.post("wallets/create", data).then(function (response) {
|
|
173
|
+
resolve(response.data);
|
|
174
|
+
}).catch(function (err) {
|
|
175
|
+
reject(err);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
146
179
|
}, {
|
|
147
180
|
key: "resendActivationEmail",
|
|
148
181
|
value: function resendActivationEmail(data) {
|
|
@@ -190,7 +223,7 @@ var Auth = /*#__PURE__*/function () {
|
|
|
190
223
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
191
224
|
while (1) switch (_context2.prev = _context2.next) {
|
|
192
225
|
case 0:
|
|
193
|
-
_axios.default.post("
|
|
226
|
+
_axios.default.post("wallets/validate-gaid", {
|
|
194
227
|
gaid: id
|
|
195
228
|
}).then(function (response) {
|
|
196
229
|
resolve(response.data);
|
|
@@ -54,6 +54,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
54
54
|
waitingFor2fa: false,
|
|
55
55
|
firebaseError: null
|
|
56
56
|
});
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "userRef", /*#__PURE__*/_react.default.createRef(null));
|
|
57
58
|
_defineProperty(_assertThisInitialized(_this), "checkTokenIsValid", function () {
|
|
58
59
|
var redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
59
60
|
var accessToken = _Auth.default.getAccessToken();
|
|
@@ -75,43 +76,44 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
75
76
|
user = _context.sent;
|
|
76
77
|
console.log('🚀 ~ file: AuthContext.js:33 ~ user:', user);
|
|
77
78
|
_Auth.default.setAccessToken(user.accessToken);
|
|
79
|
+
_axios.default.defaults.headers.common.Authorization = "Bearer ".concat(user.accessToken);
|
|
80
|
+
_this.setUser(user);
|
|
78
81
|
_this.setState({
|
|
79
|
-
user: user,
|
|
80
82
|
isFetchingUser: false
|
|
81
83
|
});
|
|
82
84
|
//if you need user immediatly
|
|
83
85
|
return _context.abrupt("return", user);
|
|
84
|
-
case
|
|
85
|
-
_context.prev =
|
|
86
|
+
case 12:
|
|
87
|
+
_context.prev = 12;
|
|
86
88
|
_context.t0 = _context["catch"](0);
|
|
87
89
|
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context.t0);
|
|
88
90
|
_context.t1 = _context.t0.code;
|
|
89
|
-
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ?
|
|
91
|
+
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 18 : _context.t1 === 'auth/requires-recent-login' ? 20 : _context.t1 === 'auth/invalid-login-credentials' ? 22 : 24;
|
|
90
92
|
break;
|
|
91
|
-
case
|
|
93
|
+
case 18:
|
|
92
94
|
// Initiate your second factor sign-in flow. (See next step.)
|
|
93
95
|
_this.setState({
|
|
94
96
|
waitingFor2fa: true,
|
|
95
97
|
firebaseError: _context.t0
|
|
96
98
|
});
|
|
97
99
|
throw _context.t0;
|
|
98
|
-
case
|
|
100
|
+
case 20:
|
|
99
101
|
// The user's last sign-in time does not meet the security threshold.
|
|
100
102
|
_this.logoutUser();
|
|
101
|
-
return _context.abrupt("break",
|
|
102
|
-
case
|
|
103
|
+
return _context.abrupt("break", 27);
|
|
104
|
+
case 22:
|
|
103
105
|
_context.t0.message = 'The credentials are not correct. Try again?';
|
|
104
106
|
throw _context.t0;
|
|
105
|
-
case
|
|
107
|
+
case 24:
|
|
106
108
|
console.log({
|
|
107
109
|
error: _context.t0
|
|
108
110
|
}); // Handle other errors, such as wrong passwords.
|
|
109
111
|
throw _context.t0;
|
|
110
|
-
case
|
|
112
|
+
case 27:
|
|
111
113
|
case "end":
|
|
112
114
|
return _context.stop();
|
|
113
115
|
}
|
|
114
|
-
}, _callee, null, [[0,
|
|
116
|
+
}, _callee, null, [[0, 12]]);
|
|
115
117
|
}));
|
|
116
118
|
return function (_x, _x2) {
|
|
117
119
|
return _ref.apply(this, arguments);
|
|
@@ -127,7 +129,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
127
129
|
//console.log(enrolledFactors);
|
|
128
130
|
selectedIndex = 0;
|
|
129
131
|
_context2.t0 = mfaResolver.hints[selectedIndex].factorId;
|
|
130
|
-
_context2.next = _context2.t0 === _auth.TotpMultiFactorGenerator.FACTOR_ID ? 5 : _context2.t0 === _auth.PhoneMultiFactorGenerator.FACTOR_ID ?
|
|
132
|
+
_context2.next = _context2.t0 === _auth.TotpMultiFactorGenerator.FACTOR_ID ? 5 : _context2.t0 === _auth.PhoneMultiFactorGenerator.FACTOR_ID ? 23 : 24;
|
|
131
133
|
break;
|
|
132
134
|
case 5:
|
|
133
135
|
otpFromAuthenticator = verificationCode; // OTP typed by the user.
|
|
@@ -139,32 +141,31 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
139
141
|
userCredential = _context2.sent;
|
|
140
142
|
user = userCredential.user;
|
|
141
143
|
_Auth.default.setAccessToken(user.accessToken);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
144
|
+
_axios.default.defaults.headers.common.Authorization = "Bearer ".concat(user.accessToken);
|
|
145
|
+
_this.setUser(user);
|
|
145
146
|
console.log('🚀 ~sucess login 2FA:');
|
|
146
147
|
// Successfully signed in!
|
|
147
|
-
_context2.next =
|
|
148
|
+
_context2.next = 22;
|
|
148
149
|
break;
|
|
149
|
-
case
|
|
150
|
-
_context2.prev =
|
|
150
|
+
case 18:
|
|
151
|
+
_context2.prev = 18;
|
|
151
152
|
_context2.t1 = _context2["catch"](7);
|
|
152
153
|
// Invalid or expired OTP.
|
|
153
154
|
console.log({
|
|
154
155
|
error: _context2.t1
|
|
155
156
|
});
|
|
156
157
|
throw _context2.t1;
|
|
157
|
-
case 21:
|
|
158
|
-
return _context2.abrupt("break", 24);
|
|
159
158
|
case 22:
|
|
160
|
-
return _context2.abrupt("break",
|
|
159
|
+
return _context2.abrupt("break", 25);
|
|
161
160
|
case 23:
|
|
162
|
-
return _context2.abrupt("break",
|
|
161
|
+
return _context2.abrupt("break", 25);
|
|
163
162
|
case 24:
|
|
163
|
+
return _context2.abrupt("break", 25);
|
|
164
|
+
case 25:
|
|
164
165
|
case "end":
|
|
165
166
|
return _context2.stop();
|
|
166
167
|
}
|
|
167
|
-
}, _callee2, null, [[7,
|
|
168
|
+
}, _callee2, null, [[7, 18]]);
|
|
168
169
|
}));
|
|
169
170
|
return function (_x3, _x4) {
|
|
170
171
|
return _ref2.apply(this, arguments);
|
|
@@ -331,9 +332,8 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
331
332
|
_defineProperty(_assertThisInitialized(_this), "logoutUser", function () {
|
|
332
333
|
var redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
333
334
|
_Auth.default.logout();
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
});
|
|
335
|
+
delete _axios.default.defaults.headers.common.Authorization;
|
|
336
|
+
_this.setUser(null);
|
|
337
337
|
if (redirect) {
|
|
338
338
|
window.location.href = "https://".concat(process.env.REACT_APP_WEBSITE_DOMAIN);
|
|
339
339
|
}
|
|
@@ -364,8 +364,8 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
364
364
|
customValidateGetUser && customValidateGetUser(user);
|
|
365
365
|
userAvatar = "".concat(process.env.REACT_APP_PHOTO_API_URL, "/media/picture/view/").concat(user._id);
|
|
366
366
|
_this.checkUserPhoto(userAvatar);
|
|
367
|
+
_this.setUser(user);
|
|
367
368
|
_this.setState({
|
|
368
|
-
user: user,
|
|
369
369
|
isFetchingUser: false
|
|
370
370
|
});
|
|
371
371
|
|
|
@@ -374,19 +374,19 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
374
374
|
|
|
375
375
|
//if you need user info immediately after call (before setState is executed), you can use this
|
|
376
376
|
return _context7.abrupt("return", user);
|
|
377
|
-
case
|
|
378
|
-
_context7.prev =
|
|
377
|
+
case 19:
|
|
378
|
+
_context7.prev = 19;
|
|
379
379
|
_context7.t0 = _context7["catch"](4);
|
|
380
380
|
_this.setState({
|
|
381
381
|
isFetchingUser: false
|
|
382
382
|
});
|
|
383
383
|
console.log("Error in getUser: ".concat(_context7.t0));
|
|
384
384
|
throw _context7.t0;
|
|
385
|
-
case
|
|
385
|
+
case 24:
|
|
386
386
|
case "end":
|
|
387
387
|
return _context7.stop();
|
|
388
388
|
}
|
|
389
|
-
}, _callee7, null, [[4,
|
|
389
|
+
}, _callee7, null, [[4, 19]]);
|
|
390
390
|
}));
|
|
391
391
|
return function (_x10) {
|
|
392
392
|
return _ref7.apply(this, arguments);
|
|
@@ -510,9 +510,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
510
510
|
case 3:
|
|
511
511
|
_yield$Auth$updateUse = _context10.sent;
|
|
512
512
|
user = _yield$Auth$updateUse.user;
|
|
513
|
-
_this.
|
|
514
|
-
user: user
|
|
515
|
-
});
|
|
513
|
+
_this.setUser(user);
|
|
516
514
|
_context10.next = 12;
|
|
517
515
|
break;
|
|
518
516
|
case 8:
|
|
@@ -703,9 +701,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
703
701
|
return _Auth.default.uploaProofOfAddress(data, ip);
|
|
704
702
|
case 3:
|
|
705
703
|
user = _context15.sent;
|
|
706
|
-
_this.
|
|
707
|
-
user: user
|
|
708
|
-
});
|
|
704
|
+
_this.setUser(user);
|
|
709
705
|
_context15.next = 11;
|
|
710
706
|
break;
|
|
711
707
|
case 7:
|
|
@@ -745,11 +741,74 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
745
741
|
return _ref16.apply(this, arguments);
|
|
746
742
|
};
|
|
747
743
|
}());
|
|
744
|
+
_defineProperty(_assertThisInitialized(_this), "createWallet", /*#__PURE__*/function () {
|
|
745
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(data) {
|
|
746
|
+
var wallet;
|
|
747
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
748
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
749
|
+
case 0:
|
|
750
|
+
_context17.prev = 0;
|
|
751
|
+
_context17.next = 3;
|
|
752
|
+
return _Auth.default.createWallet(data);
|
|
753
|
+
case 3:
|
|
754
|
+
wallet = _context17.sent;
|
|
755
|
+
return _context17.abrupt("return", wallet);
|
|
756
|
+
case 7:
|
|
757
|
+
_context17.prev = 7;
|
|
758
|
+
_context17.t0 = _context17["catch"](0);
|
|
759
|
+
console.log("Error creating wallet: ".concat(_context17.t0));
|
|
760
|
+
throw _context17.t0;
|
|
761
|
+
case 11:
|
|
762
|
+
case "end":
|
|
763
|
+
return _context17.stop();
|
|
764
|
+
}
|
|
765
|
+
}, _callee17, null, [[0, 7]]);
|
|
766
|
+
}));
|
|
767
|
+
return function (_x20) {
|
|
768
|
+
return _ref17.apply(this, arguments);
|
|
769
|
+
};
|
|
770
|
+
}());
|
|
748
771
|
_defineProperty(_assertThisInitialized(_this), "setUser", function (user) {
|
|
772
|
+
_this.userRef.current = user;
|
|
749
773
|
_this.setState({
|
|
750
774
|
user: user
|
|
751
775
|
});
|
|
752
776
|
});
|
|
777
|
+
_defineProperty(_assertThisInitialized(_this), "fetchLastTime", /*#__PURE__*/function () {
|
|
778
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(projectName, page, userId) {
|
|
779
|
+
var filterBody, response;
|
|
780
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
781
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
782
|
+
case 0:
|
|
783
|
+
_context18.prev = 0;
|
|
784
|
+
filterBody = {
|
|
785
|
+
projectName: projectName,
|
|
786
|
+
page: page
|
|
787
|
+
};
|
|
788
|
+
if (userId) {
|
|
789
|
+
filterBody.userId = userId;
|
|
790
|
+
}
|
|
791
|
+
_context18.next = 5;
|
|
792
|
+
return _Auth.default.fetchTrackingUserLastTime({
|
|
793
|
+
filter: filterBody
|
|
794
|
+
});
|
|
795
|
+
case 5:
|
|
796
|
+
response = _context18.sent;
|
|
797
|
+
return _context18.abrupt("return", response);
|
|
798
|
+
case 9:
|
|
799
|
+
_context18.prev = 9;
|
|
800
|
+
_context18.t0 = _context18["catch"](0);
|
|
801
|
+
console.log(' error', _context18.t0);
|
|
802
|
+
case 12:
|
|
803
|
+
case "end":
|
|
804
|
+
return _context18.stop();
|
|
805
|
+
}
|
|
806
|
+
}, _callee18, null, [[0, 9]]);
|
|
807
|
+
}));
|
|
808
|
+
return function (_x21, _x22, _x23) {
|
|
809
|
+
return _ref18.apply(this, arguments);
|
|
810
|
+
};
|
|
811
|
+
}());
|
|
753
812
|
return _this;
|
|
754
813
|
}
|
|
755
814
|
_createClass(AuthProviderClass, [{
|
|
@@ -775,6 +834,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
775
834
|
var children = this.props.children;
|
|
776
835
|
return /*#__PURE__*/_react.default.createElement(AuthContext.Provider, {
|
|
777
836
|
value: _objectSpread(_objectSpread({}, this.state), {}, {
|
|
837
|
+
userRef: this.userRef,
|
|
778
838
|
checkUserIsValid: this.checkUserIsValid,
|
|
779
839
|
checkTokenIsValid: this.checkTokenIsValid,
|
|
780
840
|
checkUserPhoto: this.checkUserPhoto,
|
|
@@ -795,6 +855,9 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
795
855
|
resendActivationEmail: this.resendActivationEmail,
|
|
796
856
|
uploaProofOfAddress: this.uploaProofOfAddress,
|
|
797
857
|
validateGreenWalletId: this.validateGreenWalletId,
|
|
858
|
+
fetchLastTime: this.fetchLastTime,
|
|
859
|
+
createWallet: this.createWallet,
|
|
860
|
+
requestUpdateEmail: _Auth.default.requestUpdateEmail,
|
|
798
861
|
setUser: this.setUser
|
|
799
862
|
})
|
|
800
863
|
}, children);
|