From 7b1973dbadd3b1a619a2d549b5098de125c7ef22 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 16 Apr 2020 10:52:52 -0400 Subject: [PATCH] trigger signup email if user doesn't have a password --- dist/bundle.es.js | 86 ++++++++++++++++++++------------------- dist/bundle.js | 6 +++ src/redux/actions/user.js | 3 ++ 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index bb1f1ea..68a44b7 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1585,6 +1585,12 @@ function doUserCheckIfEmailExists(email) { dispatch({ type: USER_PASSWORD_EXISTS }); + } else { + // If they don't have a password, they will need to use the email verification api + Lbryio.call('user_email', 'resend_token', { + email, + only_if_expired: true + }, 'post'); } }; @@ -1653,48 +1659,46 @@ function doUserSignIn(email, password) { }; } function doUserSignUp(email, password) { - return dispatch => { - return new Promise((resolve, reject) => { - dispatch({ - type: USER_EMAIL_NEW_STARTED, - email - }); - - const success = () => { - dispatch({ - type: USER_EMAIL_NEW_SUCCESS, - data: { - email - } - }); - dispatch(doUserFetch()); - resolve(); - }; - - const failure = error => { - if (error.response && error.response.status === 409) { - dispatch({ - type: USER_EMAIL_NEW_EXISTS - }); - } - - dispatch({ - type: USER_EMAIL_NEW_FAILURE, - data: { - error - } - }); - reject(error); - }; - - Lbryio.call('user', 'signup', { - email, - ...(password ? { - password - } : {}) - }, 'post').then(success, failure); + return dispatch => new Promise((resolve, reject) => { + dispatch({ + type: USER_EMAIL_NEW_STARTED, + email }); - }; + + const success = () => { + dispatch({ + type: USER_EMAIL_NEW_SUCCESS, + data: { + email + } + }); + dispatch(doUserFetch()); + resolve(); + }; + + const failure = error => { + if (error.response && error.response.status === 409) { + dispatch({ + type: USER_EMAIL_NEW_EXISTS + }); + } + + dispatch({ + type: USER_EMAIL_NEW_FAILURE, + data: { + error + } + }); + reject(error); + }; + + Lbryio.call('user', 'signup', { + email, + ...(password ? { + password + } : {}) + }, 'post').then(success, failure); + }); } function doUserPasswordReset(email) { return dispatch => { diff --git a/dist/bundle.js b/dist/bundle.js index 8219a5f..da6c2ff 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -5303,6 +5303,12 @@ function doUserCheckIfEmailExists(email) { dispatch({ type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_PASSWORD_EXISTS"] }); + } else { + // If they don't have a password, they will need to use the email verification api + lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].call('user_email', 'resend_token', { + email: email, + only_if_expired: true + }, 'post'); } }; diff --git a/src/redux/actions/user.js b/src/redux/actions/user.js index 047785c..fda8762 100644 --- a/src/redux/actions/user.js +++ b/src/redux/actions/user.js @@ -326,6 +326,9 @@ export function doUserCheckIfEmailExists(email) { dispatch({ type: ACTIONS.USER_PASSWORD_EXISTS, }); + } else { + // If they don't have a password, they will need to use the email verification api + Lbryio.call('user_email', 'resend_token', { email, only_if_expired: true }, 'post'); } }; -- 2.45.2