trigger signup email if user doesn't have a password #94

Merged
neb-b merged 1 commit from signup into master 2020-04-16 16:54:04 +02:00
3 changed files with 54 additions and 41 deletions

86
dist/bundle.es.js vendored
View file

@ -1585,6 +1585,12 @@ function doUserCheckIfEmailExists(email) {
dispatch({ dispatch({
type: USER_PASSWORD_EXISTS 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) { function doUserSignUp(email, password) {
return dispatch => { return dispatch => new Promise((resolve, reject) => {
return new Promise((resolve, reject) => { dispatch({
dispatch({ type: USER_EMAIL_NEW_STARTED,
type: USER_EMAIL_NEW_STARTED, email
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);
}); });
};
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) { function doUserPasswordReset(email) {
return dispatch => { return dispatch => {

6
dist/bundle.js vendored
View file

@ -5303,6 +5303,12 @@ function doUserCheckIfEmailExists(email) {
dispatch({ dispatch({
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_PASSWORD_EXISTS"] 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');
} }
}; };

View file

@ -326,6 +326,9 @@ export function doUserCheckIfEmailExists(email) {
dispatch({ dispatch({
type: ACTIONS.USER_PASSWORD_EXISTS, 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');
} }
}; };