@stokr/components-library 2.0.0-beta.2 → 2.0.0-beta.20
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/2FA/Connect2FA.js +58 -16
- package/dist/components/2FA/EnterCode.js +2 -1
- package/dist/components/2FA/InstallAuthApp.js +41 -11
- package/dist/components/2FA/Sucess2FA.js +15 -6
- package/dist/components/2FA/disable-2fa-flow.js +10 -133
- package/dist/components/2FA/enable-2fa-flow.js +2 -2
- package/dist/components/2FA/main-flow.js +8 -4
- package/dist/components/2FA/main-flow.stories.js +1 -1
- package/dist/components/ComponentScroll/ComponentScroll.js +4 -2
- package/dist/components/ComponentScroll/ComponentScroll.styles.js +7 -5
- package/dist/components/ComponentWrapper/ComponentWrapper.styles.js +9 -7
- package/dist/components/CryptoAddress/CryptoAddress.js +6 -3
- package/dist/components/ForgotPasswordModal/ForgotPasswordModal.stories.js +4 -1
- package/dist/components/Header/Header.styles.js +1 -1
- package/dist/components/Input/OtpInput.js +54 -8
- package/dist/components/MainMenu/MainMenu.js +2 -2
- package/dist/components/Modal/Modal.styles.js +5 -2
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.js +10 -3
- package/dist/components/RegisterConfirmModal/RegisterConfirmModal.stories.js +6 -2
- package/dist/components/RegisterModal/RegisterModal.js +1 -22
- package/dist/components/Switch/Switch.js +13 -6
- package/dist/components/Switch/Switch.styles.js +3 -3
- package/dist/components/TermsModal/TermsModal.js +1 -1
- package/dist/components/TextLink/TextLink.styles.js +4 -2
- package/dist/components/VerifyEmailModal/VerifyEmailModal.js +163 -0
- package/dist/components/VerifyEmailModal/VerifyEmailModal.stories.js +64 -0
- package/dist/components/headerHo/HeaderHo.js +162 -104
- package/dist/components/headerHo/HeaderHo.stories.js +5 -1
- package/dist/context/Auth.js +41 -22
- package/dist/context/AuthContext.js +305 -218
- package/dist/static/images/avatar-placeholder.png +0 -0
- package/dist/static/images/google_auth.png +0 -0
- package/dist/utils/customHooks.js +60 -2
- package/package.json +1 -1
|
@@ -53,7 +53,9 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
53
53
|
avatar: _avatarPlaceholder.default,
|
|
54
54
|
userMfaEnrollment: null,
|
|
55
55
|
waitingFor2fa: false,
|
|
56
|
-
firebaseError: null
|
|
56
|
+
firebaseError: null,
|
|
57
|
+
verifyEmailError: null,
|
|
58
|
+
isVerifyingEmail: false
|
|
57
59
|
});
|
|
58
60
|
_defineProperty(_assertThisInitialized(_this), "checkTokenIsValid", function () {
|
|
59
61
|
var redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
@@ -74,6 +76,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
74
76
|
return _Auth.default.login(email, password);
|
|
75
77
|
case 3:
|
|
76
78
|
user = _context.sent;
|
|
79
|
+
console.log('🚀 ~ file: AuthContext.js:50 ~ user:', user);
|
|
77
80
|
_Auth.default.setAccessToken(user.accessToken);
|
|
78
81
|
_this.setState({
|
|
79
82
|
firebaseUser: user,
|
|
@@ -81,251 +84,248 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
81
84
|
});
|
|
82
85
|
//if you need user immediatly
|
|
83
86
|
return _context.abrupt("return", user);
|
|
84
|
-
case
|
|
85
|
-
_context.prev =
|
|
87
|
+
case 10:
|
|
88
|
+
_context.prev = 10;
|
|
86
89
|
_context.t0 = _context["catch"](0);
|
|
87
90
|
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context.t0);
|
|
88
91
|
_context.t1 = _context.t0.code;
|
|
89
|
-
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ?
|
|
92
|
+
_context.next = _context.t1 === 'auth/multi-factor-auth-required' ? 16 : _context.t1 === 'auth/requires-recent-login' ? 18 : _context.t1 === 'auth/invalid-login-credentials' ? 20 : 22;
|
|
90
93
|
break;
|
|
91
|
-
case
|
|
94
|
+
case 16:
|
|
92
95
|
// Initiate your second factor sign-in flow. (See next step.)
|
|
93
96
|
_this.setState({
|
|
94
97
|
waitingFor2fa: true,
|
|
95
98
|
firebaseError: _context.t0
|
|
96
99
|
});
|
|
97
100
|
throw _context.t0;
|
|
98
|
-
case
|
|
101
|
+
case 18:
|
|
99
102
|
// The user's last sign-in time does not meet the security threshold.
|
|
100
103
|
_this.logoutUser();
|
|
101
|
-
return _context.abrupt("break",
|
|
102
|
-
case
|
|
104
|
+
return _context.abrupt("break", 25);
|
|
105
|
+
case 20:
|
|
103
106
|
_context.t0.message = 'The credentials are not correct. Try again?';
|
|
104
107
|
throw _context.t0;
|
|
105
|
-
case
|
|
108
|
+
case 22:
|
|
106
109
|
console.log({
|
|
107
110
|
error: _context.t0
|
|
108
111
|
}); // Handle other errors, such as wrong passwords.
|
|
109
112
|
throw _context.t0;
|
|
110
|
-
case
|
|
113
|
+
case 25:
|
|
111
114
|
case "end":
|
|
112
115
|
return _context.stop();
|
|
113
116
|
}
|
|
114
|
-
}, _callee, null, [[0,
|
|
117
|
+
}, _callee, null, [[0, 10]]);
|
|
115
118
|
}));
|
|
116
119
|
return function (_x, _x2) {
|
|
117
120
|
return _ref.apply(this, arguments);
|
|
118
121
|
};
|
|
119
122
|
}());
|
|
120
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
121
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(
|
|
122
|
-
var
|
|
123
|
+
_defineProperty(_assertThisInitialized(_this), "createUser", /*#__PURE__*/function () {
|
|
124
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(email, password) {
|
|
125
|
+
var user;
|
|
123
126
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
124
127
|
while (1) switch (_context2.prev = _context2.next) {
|
|
128
|
+
case 0:
|
|
129
|
+
_context2.prev = 0;
|
|
130
|
+
_context2.next = 3;
|
|
131
|
+
return _Auth.default.createUser(email, password);
|
|
132
|
+
case 3:
|
|
133
|
+
user = _context2.sent;
|
|
134
|
+
_Auth.default.setAccessToken(user.accessToken);
|
|
135
|
+
|
|
136
|
+
// this.setState({
|
|
137
|
+
// firebaseUser: user,
|
|
138
|
+
// isFetchingUser: false,
|
|
139
|
+
// })
|
|
140
|
+
// return user
|
|
141
|
+
_context2.next = 11;
|
|
142
|
+
break;
|
|
143
|
+
case 7:
|
|
144
|
+
_context2.prev = 7;
|
|
145
|
+
_context2.t0 = _context2["catch"](0);
|
|
146
|
+
console.log('🚀 ~ file: AuthContext.js:56 ~ error:', _context2.t0);
|
|
147
|
+
throw _context2.t0;
|
|
148
|
+
case 11:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context2.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee2, null, [[0, 7]]);
|
|
153
|
+
}));
|
|
154
|
+
return function (_x3, _x4) {
|
|
155
|
+
return _ref2.apply(this, arguments);
|
|
156
|
+
};
|
|
157
|
+
}());
|
|
158
|
+
_defineProperty(_assertThisInitialized(_this), "loginUserWithTotp", /*#__PURE__*/function () {
|
|
159
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(verificationCode, error) {
|
|
160
|
+
var mfaResolver, selectedIndex, otpFromAuthenticator, multiFactorAssertion, userCredential, user;
|
|
161
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
162
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
125
163
|
case 0:
|
|
126
164
|
mfaResolver = (0, _auth.getMultiFactorResolver)((0, _auth.getAuth)(), error); // const enrolledFactors = mfaResolver.hints.map(info => info.displayName);
|
|
127
165
|
//console.log(enrolledFactors);
|
|
128
166
|
selectedIndex = 0;
|
|
129
|
-
|
|
130
|
-
|
|
167
|
+
_context3.t0 = mfaResolver.hints[selectedIndex].factorId;
|
|
168
|
+
_context3.next = _context3.t0 === _auth.TotpMultiFactorGenerator.FACTOR_ID ? 5 : _context3.t0 === _auth.PhoneMultiFactorGenerator.FACTOR_ID ? 21 : 22;
|
|
131
169
|
break;
|
|
132
170
|
case 5:
|
|
133
171
|
otpFromAuthenticator = verificationCode; // OTP typed by the user.
|
|
134
172
|
multiFactorAssertion = _auth.TotpMultiFactorGenerator.assertionForSignIn(mfaResolver.hints[selectedIndex].uid, otpFromAuthenticator);
|
|
135
|
-
|
|
136
|
-
|
|
173
|
+
_context3.prev = 7;
|
|
174
|
+
_context3.next = 10;
|
|
137
175
|
return mfaResolver.resolveSignIn(multiFactorAssertion);
|
|
138
176
|
case 10:
|
|
139
|
-
userCredential =
|
|
177
|
+
userCredential = _context3.sent;
|
|
140
178
|
user = userCredential.user;
|
|
141
179
|
_Auth.default.setAccessToken(user.accessToken);
|
|
142
180
|
_this.setState({
|
|
143
181
|
firebaseUser: user
|
|
144
182
|
});
|
|
145
|
-
|
|
183
|
+
_context3.next = 20;
|
|
146
184
|
break;
|
|
147
185
|
case 16:
|
|
148
|
-
|
|
149
|
-
|
|
186
|
+
_context3.prev = 16;
|
|
187
|
+
_context3.t1 = _context3["catch"](7);
|
|
150
188
|
// Invalid or expired OTP.
|
|
151
189
|
console.log({
|
|
152
|
-
error:
|
|
190
|
+
error: _context3.t1
|
|
153
191
|
});
|
|
154
|
-
throw
|
|
192
|
+
throw _context3.t1;
|
|
155
193
|
case 20:
|
|
156
|
-
return
|
|
194
|
+
return _context3.abrupt("break", 23);
|
|
157
195
|
case 21:
|
|
158
|
-
return
|
|
196
|
+
return _context3.abrupt("break", 23);
|
|
159
197
|
case 22:
|
|
160
|
-
return
|
|
198
|
+
return _context3.abrupt("break", 23);
|
|
161
199
|
case 23:
|
|
162
200
|
case "end":
|
|
163
|
-
return
|
|
201
|
+
return _context3.stop();
|
|
164
202
|
}
|
|
165
|
-
},
|
|
203
|
+
}, _callee3, null, [[7, 16]]);
|
|
166
204
|
}));
|
|
167
|
-
return function (
|
|
168
|
-
return
|
|
205
|
+
return function (_x5, _x6) {
|
|
206
|
+
return _ref3.apply(this, arguments);
|
|
169
207
|
};
|
|
170
208
|
}());
|
|
171
209
|
_defineProperty(_assertThisInitialized(_this), "generateTotpSecret", /*#__PURE__*/function () {
|
|
172
|
-
var
|
|
210
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(user) {
|
|
173
211
|
var appName,
|
|
174
212
|
multiFactorSession,
|
|
175
213
|
totpSecret,
|
|
176
214
|
totpUri,
|
|
177
215
|
secret,
|
|
178
|
-
|
|
179
|
-
return _regeneratorRuntime().wrap(function
|
|
180
|
-
while (1) switch (
|
|
216
|
+
_args4 = arguments;
|
|
217
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
218
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
181
219
|
case 0:
|
|
182
|
-
appName =
|
|
183
|
-
|
|
184
|
-
|
|
220
|
+
appName = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 'STOKR';
|
|
221
|
+
_context4.prev = 1;
|
|
222
|
+
_context4.next = 4;
|
|
185
223
|
return (0, _auth.multiFactor)(user).getSession();
|
|
186
224
|
case 4:
|
|
187
|
-
multiFactorSession =
|
|
188
|
-
|
|
225
|
+
multiFactorSession = _context4.sent;
|
|
226
|
+
_context4.next = 7;
|
|
189
227
|
return _auth.TotpMultiFactorGenerator.generateSecret(multiFactorSession);
|
|
190
228
|
case 7:
|
|
191
|
-
totpSecret =
|
|
229
|
+
totpSecret = _context4.sent;
|
|
192
230
|
totpUri = totpSecret.generateQrCodeUrl(user.email, appName); // Also display this key:
|
|
193
231
|
secret = totpSecret.secretKey;
|
|
194
|
-
return
|
|
232
|
+
return _context4.abrupt("return", {
|
|
195
233
|
totpUri: totpUri,
|
|
196
234
|
totpSecret: totpSecret
|
|
197
235
|
});
|
|
198
236
|
case 13:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
console.log('🚀 ~ file: AuthContext.js:51 ~ error:',
|
|
202
|
-
throw
|
|
237
|
+
_context4.prev = 13;
|
|
238
|
+
_context4.t0 = _context4["catch"](1);
|
|
239
|
+
console.log('🚀 ~ file: AuthContext.js:51 ~ error:', _context4.t0);
|
|
240
|
+
throw _context4.t0;
|
|
203
241
|
case 17:
|
|
204
242
|
case "end":
|
|
205
|
-
return
|
|
243
|
+
return _context4.stop();
|
|
206
244
|
}
|
|
207
|
-
},
|
|
245
|
+
}, _callee4, null, [[1, 13]]);
|
|
208
246
|
}));
|
|
209
|
-
return function (
|
|
210
|
-
return
|
|
247
|
+
return function (_x7) {
|
|
248
|
+
return _ref4.apply(this, arguments);
|
|
211
249
|
};
|
|
212
250
|
}());
|
|
213
|
-
_defineProperty(_assertThisInitialized(_this), "unenrollUser2FA", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
251
|
+
_defineProperty(_assertThisInitialized(_this), "unenrollUser2FA", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
214
252
|
var _this$state, userMfaEnrollment, user, i;
|
|
215
|
-
return _regeneratorRuntime().wrap(function
|
|
216
|
-
while (1) switch (
|
|
253
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
254
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
217
255
|
case 0:
|
|
218
256
|
_this$state = _this.state, userMfaEnrollment = _this$state.userMfaEnrollment, user = _this$state.user;
|
|
219
257
|
if (!((userMfaEnrollment === null || userMfaEnrollment === void 0 ? void 0 : userMfaEnrollment.length) === 0)) {
|
|
220
|
-
|
|
258
|
+
_context5.next = 4;
|
|
221
259
|
break;
|
|
222
260
|
}
|
|
223
261
|
console.log('User is not enrolled in 2FA');
|
|
224
|
-
return
|
|
262
|
+
return _context5.abrupt("return");
|
|
225
263
|
case 4:
|
|
226
|
-
|
|
264
|
+
_context5.prev = 4;
|
|
227
265
|
i = 0;
|
|
228
266
|
case 6:
|
|
229
267
|
if (!(i < userMfaEnrollment.length)) {
|
|
230
|
-
|
|
268
|
+
_context5.next = 12;
|
|
231
269
|
break;
|
|
232
270
|
}
|
|
233
|
-
|
|
271
|
+
_context5.next = 9;
|
|
234
272
|
return (0, _auth.multiFactor)(user).unenroll(userMfaEnrollment[i].uid);
|
|
235
273
|
case 9:
|
|
236
274
|
i++;
|
|
237
|
-
|
|
275
|
+
_context5.next = 6;
|
|
238
276
|
break;
|
|
239
277
|
case 12:
|
|
240
|
-
|
|
278
|
+
_context5.next = 18;
|
|
241
279
|
break;
|
|
242
280
|
case 14:
|
|
243
|
-
|
|
244
|
-
|
|
281
|
+
_context5.prev = 14;
|
|
282
|
+
_context5.t0 = _context5["catch"](4);
|
|
245
283
|
console.log({
|
|
246
|
-
error:
|
|
284
|
+
error: _context5.t0
|
|
247
285
|
});
|
|
248
|
-
throw
|
|
249
|
-
case
|
|
286
|
+
throw _context5.t0;
|
|
287
|
+
case 18:
|
|
250
288
|
case "end":
|
|
251
|
-
return
|
|
289
|
+
return _context5.stop();
|
|
252
290
|
}
|
|
253
|
-
},
|
|
291
|
+
}, _callee5, null, [[4, 14]]);
|
|
254
292
|
})));
|
|
255
293
|
_defineProperty(_assertThisInitialized(_this), "checkMfaEnrollment", function (user) {
|
|
256
294
|
var checkMfaEnrollment = (0, _auth.multiFactor)(user).enrolledFactors;
|
|
295
|
+
console.log('🚀 ~ file: AuthContext.js:173 ~ checkMfaEnrollment:', checkMfaEnrollment);
|
|
257
296
|
_this.setState({
|
|
258
297
|
userMfaEnrollment: checkMfaEnrollment
|
|
259
298
|
});
|
|
260
299
|
return checkMfaEnrollment;
|
|
261
300
|
});
|
|
262
301
|
_defineProperty(_assertThisInitialized(_this), "enrollUserToTotp", /*#__PURE__*/function () {
|
|
263
|
-
var
|
|
302
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(user, totpSecret, verificationCode, displayName) {
|
|
264
303
|
var multiFactorAssertion;
|
|
265
|
-
return _regeneratorRuntime().wrap(function
|
|
266
|
-
while (1) switch (
|
|
304
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
305
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
267
306
|
case 0:
|
|
268
|
-
|
|
307
|
+
_context6.prev = 0;
|
|
269
308
|
// Finalize the enrollment.
|
|
270
309
|
multiFactorAssertion = _auth.TotpMultiFactorGenerator.assertionForEnrollment(totpSecret, verificationCode);
|
|
271
|
-
|
|
310
|
+
_context6.next = 4;
|
|
272
311
|
return (0, _auth.multiFactor)(user).enroll(multiFactorAssertion, displayName);
|
|
273
312
|
case 4:
|
|
274
|
-
|
|
313
|
+
_context6.next = 9;
|
|
275
314
|
break;
|
|
276
315
|
case 6:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
throw
|
|
316
|
+
_context6.prev = 6;
|
|
317
|
+
_context6.t0 = _context6["catch"](0);
|
|
318
|
+
throw _context6.t0;
|
|
280
319
|
case 9:
|
|
281
320
|
case "end":
|
|
282
|
-
return
|
|
321
|
+
return _context6.stop();
|
|
283
322
|
}
|
|
284
|
-
},
|
|
323
|
+
}, _callee6, null, [[0, 6]]);
|
|
285
324
|
}));
|
|
286
|
-
return function (
|
|
287
|
-
return
|
|
325
|
+
return function (_x8, _x9, _x10, _x11) {
|
|
326
|
+
return _ref6.apply(this, arguments);
|
|
288
327
|
};
|
|
289
328
|
}());
|
|
290
|
-
_defineProperty(_assertThisInitialized(_this), "activateUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
291
|
-
var _yield$Auth$activateU, user, access_token;
|
|
292
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
293
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
294
|
-
case 0:
|
|
295
|
-
_context6.prev = 0;
|
|
296
|
-
_context6.next = 3;
|
|
297
|
-
return _Auth.default.activateUser();
|
|
298
|
-
case 3:
|
|
299
|
-
_yield$Auth$activateU = _context6.sent;
|
|
300
|
-
user = _yield$Auth$activateU.user;
|
|
301
|
-
access_token = _yield$Auth$activateU.access_token;
|
|
302
|
-
_axios.default.defaults.headers.common.Authorization = "Bearer ".concat(access_token);
|
|
303
|
-
_Auth.default.setAccessToken(access_token);
|
|
304
|
-
_this.setState({
|
|
305
|
-
user: user,
|
|
306
|
-
isFetchingUser: false
|
|
307
|
-
});
|
|
308
|
-
_context6.next = 16;
|
|
309
|
-
break;
|
|
310
|
-
case 11:
|
|
311
|
-
_context6.prev = 11;
|
|
312
|
-
_context6.t0 = _context6["catch"](0);
|
|
313
|
-
console.log('Error activating user: ', _context6.t0);
|
|
314
|
-
_this.props.navigate('/oops', {
|
|
315
|
-
state: {
|
|
316
|
-
message: 'This activation token has expired.',
|
|
317
|
-
hasActivationTokenExpired: true
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
_this.setState({
|
|
321
|
-
isFetchingUser: false
|
|
322
|
-
});
|
|
323
|
-
case 16:
|
|
324
|
-
case "end":
|
|
325
|
-
return _context6.stop();
|
|
326
|
-
}
|
|
327
|
-
}, _callee6, null, [[0, 11]]);
|
|
328
|
-
})));
|
|
329
329
|
_defineProperty(_assertThisInitialized(_this), "logoutUser", function () {
|
|
330
330
|
var redirect = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
331
331
|
_Auth.default.logout();
|
|
@@ -439,7 +439,11 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
439
439
|
if (!user) {
|
|
440
440
|
throw new Error('User is not defined');
|
|
441
441
|
}
|
|
442
|
-
if (!(user !== null && user !== void 0 && user.
|
|
442
|
+
if (!(user !== null && user !== void 0 && user.emailVerified) && !window.location.href.includes('signup.')) {
|
|
443
|
+
window.location.href = "https://signup.".concat(process.env.REACT_APP_WEBSITE_DOMAIN, "/resend-activation-email");
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
if (!(user !== null && user !== void 0 && user.country) && (user === null || user === void 0 ? void 0 : user.user_type) === 'investor' && !window.location.href.includes('signup.')) {
|
|
443
447
|
window.location.href = "https://signup.".concat(process.env.REACT_APP_WEBSITE_DOMAIN, "/welcome");
|
|
444
448
|
return false;
|
|
445
449
|
}
|
|
@@ -484,7 +488,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
484
488
|
}
|
|
485
489
|
}, _callee8, null, [[0, 14]]);
|
|
486
490
|
}));
|
|
487
|
-
return function (
|
|
491
|
+
return function (_x12, _x13) {
|
|
488
492
|
return _ref8.apply(this, arguments);
|
|
489
493
|
};
|
|
490
494
|
}());
|
|
@@ -517,7 +521,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
517
521
|
})));
|
|
518
522
|
_defineProperty(_assertThisInitialized(_this), "replaceLocationPathName", function () {
|
|
519
523
|
var pathname = _this.props.location.pathname;
|
|
520
|
-
if (pathname === '/login' || pathname === '/signup'
|
|
524
|
+
if (pathname === '/login' || pathname === '/signup') {
|
|
521
525
|
_this.props.navigate('/');
|
|
522
526
|
}
|
|
523
527
|
});
|
|
@@ -547,7 +551,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
547
551
|
}
|
|
548
552
|
}, _callee10, null, [[0, 8]]);
|
|
549
553
|
}));
|
|
550
|
-
return function (
|
|
554
|
+
return function (_x14) {
|
|
551
555
|
return _ref10.apply(this, arguments);
|
|
552
556
|
};
|
|
553
557
|
}());
|
|
@@ -605,7 +609,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
605
609
|
}
|
|
606
610
|
}, _callee11, null, [[4, 19]]);
|
|
607
611
|
}));
|
|
608
|
-
return function (
|
|
612
|
+
return function (_x15) {
|
|
609
613
|
return _ref11.apply(this, arguments);
|
|
610
614
|
};
|
|
611
615
|
}());
|
|
@@ -662,133 +666,214 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
662
666
|
}
|
|
663
667
|
}, _callee12, null, [[4, 18]]);
|
|
664
668
|
}));
|
|
665
|
-
return function (
|
|
669
|
+
return function (_x16) {
|
|
666
670
|
return _ref12.apply(this, arguments);
|
|
667
671
|
};
|
|
668
672
|
}());
|
|
669
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
670
|
-
var
|
|
671
|
-
|
|
672
|
-
|
|
673
|
+
_defineProperty(_assertThisInitialized(_this), "handleVerifyEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
674
|
+
var location, query, oobCode, email;
|
|
675
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
676
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
677
|
+
case 0:
|
|
678
|
+
_this.setState({
|
|
679
|
+
isVerifyingEmail: true
|
|
680
|
+
});
|
|
681
|
+
location = _this.props.location;
|
|
682
|
+
query = new URLSearchParams(location.search);
|
|
683
|
+
_context13.prev = 3;
|
|
684
|
+
oobCode = query.get('oobCode');
|
|
685
|
+
_context13.next = 7;
|
|
686
|
+
return _Auth.default.handleVerifyEmail(oobCode);
|
|
687
|
+
case 7:
|
|
688
|
+
_this.setState({
|
|
689
|
+
isVerifyingEmail: false
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
//proceed to signup flow immediately after success
|
|
693
|
+
window.location.href = "https://signup.".concat(process.env.REACT_APP_WEBSITE_DOMAIN, "/welcome");
|
|
694
|
+
// this.getUser()
|
|
695
|
+
_context13.next = 27;
|
|
696
|
+
break;
|
|
697
|
+
case 11:
|
|
698
|
+
_context13.prev = 11;
|
|
699
|
+
_context13.t0 = _context13["catch"](3);
|
|
700
|
+
_context13.t1 = _context13.t0 === null || _context13.t0 === void 0 ? void 0 : _context13.t0.code;
|
|
701
|
+
_context13.next = _context13.t1 === 'auth/expired-action-code' ? 16 : _context13.t1 === 'auth/invalid-action-code' ? 20 : _context13.t1 === 'auth/user-disabled' ? 22 : 24;
|
|
702
|
+
break;
|
|
703
|
+
case 16:
|
|
704
|
+
_context13.t0.message = 'The activation link has expired. We are sending you a new one right now.';
|
|
705
|
+
email = query.get('email');
|
|
706
|
+
if (email) {
|
|
707
|
+
_context13.t0.email = email;
|
|
708
|
+
//Auth.resendActivationEmail(email)
|
|
709
|
+
}
|
|
710
|
+
return _context13.abrupt("break", 25);
|
|
711
|
+
case 20:
|
|
712
|
+
_context13.t0.message = 'This link is invalid. Please try verifying email again.';
|
|
713
|
+
return _context13.abrupt("break", 25);
|
|
714
|
+
case 22:
|
|
715
|
+
_context13.t0.message = 'Your account has been disabled. Please contact our support.';
|
|
716
|
+
return _context13.abrupt("break", 25);
|
|
717
|
+
case 24:
|
|
718
|
+
return _context13.abrupt("break", 25);
|
|
719
|
+
case 25:
|
|
720
|
+
console.log('🚀 ~ file: AuthContext.js:446 ~ error:', _context13.t0);
|
|
721
|
+
_this.setState({
|
|
722
|
+
verifyEmailError: _context13.t0,
|
|
723
|
+
isVerifyingEmail: false,
|
|
724
|
+
isFetchingUser: false
|
|
725
|
+
});
|
|
726
|
+
//throw error
|
|
727
|
+
case 27:
|
|
728
|
+
case "end":
|
|
729
|
+
return _context13.stop();
|
|
730
|
+
}
|
|
731
|
+
}, _callee13, null, [[3, 11]]);
|
|
732
|
+
})));
|
|
733
|
+
_defineProperty(_assertThisInitialized(_this), "handleResetPassword", /*#__PURE__*/function () {
|
|
734
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(password) {
|
|
735
|
+
var location, query, oobCode;
|
|
736
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
737
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
673
738
|
case 0:
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
739
|
+
location = _this.props.location;
|
|
740
|
+
_context14.prev = 1;
|
|
741
|
+
query = new URLSearchParams(location.search);
|
|
742
|
+
oobCode = query.get('oobCode');
|
|
743
|
+
_context14.next = 6;
|
|
744
|
+
return _Auth.default.handleResetPassword(oobCode, password);
|
|
745
|
+
case 6:
|
|
746
|
+
_context14.next = 21;
|
|
679
747
|
break;
|
|
680
|
-
case
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
748
|
+
case 8:
|
|
749
|
+
_context14.prev = 8;
|
|
750
|
+
_context14.t0 = _context14["catch"](1);
|
|
751
|
+
_context14.t1 = _context14.t0 === null || _context14.t0 === void 0 ? void 0 : _context14.t0.code;
|
|
752
|
+
_context14.next = _context14.t1 === 'auth/expired-action-code' ? 13 : _context14.t1 === 'auth/invalid-action-code' ? 15 : _context14.t1 === 'auth/user-disabled' ? 17 : 19;
|
|
753
|
+
break;
|
|
754
|
+
case 13:
|
|
755
|
+
_context14.t0.message = 'This link has expired. Please try reseting password again.';
|
|
756
|
+
return _context14.abrupt("break", 20);
|
|
757
|
+
case 15:
|
|
758
|
+
_context14.t0.message = 'This link is invalid. Please try reseting password again.';
|
|
759
|
+
return _context14.abrupt("break", 20);
|
|
760
|
+
case 17:
|
|
761
|
+
_context14.t0.message = 'Your account has been disabled. Please contact our support.';
|
|
762
|
+
return _context14.abrupt("break", 20);
|
|
763
|
+
case 19:
|
|
764
|
+
return _context14.abrupt("break", 20);
|
|
765
|
+
case 20:
|
|
766
|
+
throw _context14.t0;
|
|
767
|
+
case 21:
|
|
686
768
|
case "end":
|
|
687
|
-
return
|
|
769
|
+
return _context14.stop();
|
|
688
770
|
}
|
|
689
|
-
},
|
|
771
|
+
}, _callee14, null, [[1, 8]]);
|
|
690
772
|
}));
|
|
691
|
-
return function (
|
|
692
|
-
return
|
|
773
|
+
return function (_x17) {
|
|
774
|
+
return _ref14.apply(this, arguments);
|
|
693
775
|
};
|
|
694
776
|
}());
|
|
695
|
-
_defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
696
|
-
return _regeneratorRuntime().wrap(function
|
|
697
|
-
while (1) switch (
|
|
777
|
+
_defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
778
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
779
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
698
780
|
case 0:
|
|
699
|
-
|
|
700
|
-
|
|
781
|
+
_context15.prev = 0;
|
|
782
|
+
_context15.next = 3;
|
|
701
783
|
return _Auth.default.sendWelcomeEmail();
|
|
702
784
|
case 3:
|
|
703
|
-
|
|
785
|
+
_context15.next = 8;
|
|
704
786
|
break;
|
|
705
787
|
case 5:
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
console.log("Error sending welcome email: ".concat(
|
|
788
|
+
_context15.prev = 5;
|
|
789
|
+
_context15.t0 = _context15["catch"](0);
|
|
790
|
+
console.log("Error sending welcome email: ".concat(_context15.t0));
|
|
709
791
|
// No need to throw error, let the app continue even if it fails
|
|
710
792
|
case 8:
|
|
711
793
|
case "end":
|
|
712
|
-
return
|
|
794
|
+
return _context15.stop();
|
|
713
795
|
}
|
|
714
|
-
},
|
|
796
|
+
}, _callee15, null, [[0, 5]]);
|
|
715
797
|
})));
|
|
716
798
|
_defineProperty(_assertThisInitialized(_this), "uploaProofOfAddress", /*#__PURE__*/function () {
|
|
717
|
-
var
|
|
799
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(data, ip) {
|
|
718
800
|
var user;
|
|
719
|
-
return _regeneratorRuntime().wrap(function
|
|
720
|
-
while (1) switch (
|
|
801
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
802
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
721
803
|
case 0:
|
|
722
|
-
|
|
723
|
-
|
|
804
|
+
_context16.prev = 0;
|
|
805
|
+
_context16.next = 3;
|
|
724
806
|
return _Auth.default.uploaProofOfAddress(data, ip);
|
|
725
807
|
case 3:
|
|
726
|
-
user =
|
|
808
|
+
user = _context16.sent;
|
|
727
809
|
_this.setUser(user);
|
|
728
|
-
|
|
810
|
+
_context16.next = 11;
|
|
729
811
|
break;
|
|
730
812
|
case 7:
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
console.log("Error uploading proof of address: ".concat(
|
|
734
|
-
throw
|
|
813
|
+
_context16.prev = 7;
|
|
814
|
+
_context16.t0 = _context16["catch"](0);
|
|
815
|
+
console.log("Error uploading proof of address: ".concat(_context16.t0));
|
|
816
|
+
throw _context16.t0;
|
|
735
817
|
case 11:
|
|
736
818
|
case "end":
|
|
737
|
-
return
|
|
819
|
+
return _context16.stop();
|
|
738
820
|
}
|
|
739
|
-
},
|
|
821
|
+
}, _callee16, null, [[0, 7]]);
|
|
740
822
|
}));
|
|
741
|
-
return function (
|
|
742
|
-
return
|
|
823
|
+
return function (_x18, _x19) {
|
|
824
|
+
return _ref16.apply(this, arguments);
|
|
743
825
|
};
|
|
744
826
|
}());
|
|
745
827
|
_defineProperty(_assertThisInitialized(_this), "validateGreenWalletId", /*#__PURE__*/function () {
|
|
746
|
-
var
|
|
747
|
-
return _regeneratorRuntime().wrap(function
|
|
748
|
-
while (1) switch (
|
|
828
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(id) {
|
|
829
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
830
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
749
831
|
case 0:
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
832
|
+
_context17.prev = 0;
|
|
833
|
+
_context17.next = 3;
|
|
834
|
+
return _Auth.default.validateGreenWalletId(id);
|
|
835
|
+
case 3:
|
|
836
|
+
return _context17.abrupt("return", _context17.sent);
|
|
837
|
+
case 6:
|
|
838
|
+
_context17.prev = 6;
|
|
839
|
+
_context17.t0 = _context17["catch"](0);
|
|
840
|
+
console.log("Error validating Green Wallet ID: ".concat(_context17.t0));
|
|
841
|
+
throw _context17.t0;
|
|
842
|
+
case 10:
|
|
758
843
|
case "end":
|
|
759
|
-
return
|
|
844
|
+
return _context17.stop();
|
|
760
845
|
}
|
|
761
|
-
},
|
|
846
|
+
}, _callee17, null, [[0, 6]]);
|
|
762
847
|
}));
|
|
763
|
-
return function (
|
|
764
|
-
return
|
|
848
|
+
return function (_x20) {
|
|
849
|
+
return _ref17.apply(this, arguments);
|
|
765
850
|
};
|
|
766
851
|
}());
|
|
767
852
|
_defineProperty(_assertThisInitialized(_this), "createWallet", /*#__PURE__*/function () {
|
|
768
|
-
var
|
|
853
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(data) {
|
|
769
854
|
var wallet;
|
|
770
|
-
return _regeneratorRuntime().wrap(function
|
|
771
|
-
while (1) switch (
|
|
855
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
856
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
772
857
|
case 0:
|
|
773
|
-
|
|
774
|
-
|
|
858
|
+
_context18.prev = 0;
|
|
859
|
+
_context18.next = 3;
|
|
775
860
|
return _Auth.default.createWallet(data);
|
|
776
861
|
case 3:
|
|
777
|
-
wallet =
|
|
778
|
-
return
|
|
862
|
+
wallet = _context18.sent;
|
|
863
|
+
return _context18.abrupt("return", wallet);
|
|
779
864
|
case 7:
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
console.log("Error creating wallet: ".concat(
|
|
783
|
-
throw
|
|
865
|
+
_context18.prev = 7;
|
|
866
|
+
_context18.t0 = _context18["catch"](0);
|
|
867
|
+
console.log("Error creating wallet: ".concat(_context18.t0));
|
|
868
|
+
throw _context18.t0;
|
|
784
869
|
case 11:
|
|
785
870
|
case "end":
|
|
786
|
-
return
|
|
871
|
+
return _context18.stop();
|
|
787
872
|
}
|
|
788
|
-
},
|
|
873
|
+
}, _callee18, null, [[0, 7]]);
|
|
789
874
|
}));
|
|
790
|
-
return function (
|
|
791
|
-
return
|
|
875
|
+
return function (_x21) {
|
|
876
|
+
return _ref18.apply(this, arguments);
|
|
792
877
|
};
|
|
793
878
|
}());
|
|
794
879
|
_defineProperty(_assertThisInitialized(_this), "setUser", function (user) {
|
|
@@ -800,12 +885,12 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
800
885
|
});
|
|
801
886
|
});
|
|
802
887
|
_defineProperty(_assertThisInitialized(_this), "fetchLastTime", /*#__PURE__*/function () {
|
|
803
|
-
var
|
|
888
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(projectName, page, userId) {
|
|
804
889
|
var filterBody, response;
|
|
805
|
-
return _regeneratorRuntime().wrap(function
|
|
806
|
-
while (1) switch (
|
|
890
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
891
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
807
892
|
case 0:
|
|
808
|
-
|
|
893
|
+
_context19.prev = 0;
|
|
809
894
|
filterBody = {
|
|
810
895
|
projectName: projectName,
|
|
811
896
|
page: page
|
|
@@ -813,25 +898,25 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
813
898
|
if (userId) {
|
|
814
899
|
filterBody.userId = userId;
|
|
815
900
|
}
|
|
816
|
-
|
|
901
|
+
_context19.next = 5;
|
|
817
902
|
return _Auth.default.fetchTrackingUserLastTime({
|
|
818
903
|
filter: filterBody
|
|
819
904
|
});
|
|
820
905
|
case 5:
|
|
821
|
-
response =
|
|
822
|
-
return
|
|
906
|
+
response = _context19.sent;
|
|
907
|
+
return _context19.abrupt("return", response);
|
|
823
908
|
case 9:
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
console.log(' error',
|
|
909
|
+
_context19.prev = 9;
|
|
910
|
+
_context19.t0 = _context19["catch"](0);
|
|
911
|
+
console.log(' error', _context19.t0);
|
|
827
912
|
case 12:
|
|
828
913
|
case "end":
|
|
829
|
-
return
|
|
914
|
+
return _context19.stop();
|
|
830
915
|
}
|
|
831
|
-
},
|
|
916
|
+
}, _callee19, null, [[0, 9]]);
|
|
832
917
|
}));
|
|
833
|
-
return function (
|
|
834
|
-
return
|
|
918
|
+
return function (_x22, _x23, _x24) {
|
|
919
|
+
return _ref19.apply(this, arguments);
|
|
835
920
|
};
|
|
836
921
|
}());
|
|
837
922
|
return _this;
|
|
@@ -839,9 +924,9 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
839
924
|
_createClass(AuthProviderClass, [{
|
|
840
925
|
key: "componentDidMount",
|
|
841
926
|
value: function componentDidMount() {
|
|
842
|
-
var isActivatingUser = window.location.href.includes('
|
|
927
|
+
var isActivatingUser = window.location.href.includes('verifyEmail');
|
|
843
928
|
if (isActivatingUser) {
|
|
844
|
-
this.
|
|
929
|
+
this.handleVerifyEmail();
|
|
845
930
|
} else {
|
|
846
931
|
this.getUser();
|
|
847
932
|
}
|
|
@@ -870,15 +955,17 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
870
955
|
checkIfPrivateInvestor: this.checkIfPrivateInvestor,
|
|
871
956
|
checkIfUserSubscribed: this.checkIfUserSubscribed,
|
|
872
957
|
sendWelcomeEmail: this.sendWelcomeEmail,
|
|
873
|
-
resendActivationEmail:
|
|
958
|
+
resendActivationEmail: _Auth.default.resendActivationEmail,
|
|
874
959
|
uploaProofOfAddress: this.uploaProofOfAddress,
|
|
875
960
|
validateGreenWalletId: this.validateGreenWalletId,
|
|
876
961
|
fetchLastTime: this.fetchLastTime,
|
|
877
962
|
createWallet: this.createWallet,
|
|
878
963
|
requestUpdateEmail: _Auth.default.requestUpdateEmail,
|
|
879
964
|
updatePassword: _Auth.default.updateUserPassword,
|
|
880
|
-
createUser:
|
|
965
|
+
createUser: this.createUser,
|
|
881
966
|
updateFirebaseUser: _Auth.default.updateFirebaseUser,
|
|
967
|
+
handleResetPassword: this.handleResetPassword,
|
|
968
|
+
handleVerifyEmail: this.handleVerifyEmail,
|
|
882
969
|
setUser: this.setUser
|
|
883
970
|
})
|
|
884
971
|
}, children);
|