add promise to userSignUp
This commit is contained in:
parent
12aefaa143
commit
11ebc51ab6
3 changed files with 92 additions and 80 deletions
60
dist/bundle.es.js
vendored
60
dist/bundle.es.js
vendored
|
@ -1654,42 +1654,46 @@ function doUserSignIn(email, password) {
|
|||
}
|
||||
function doUserSignUp(email, password) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: USER_EMAIL_NEW_STARTED,
|
||||
email
|
||||
});
|
||||
|
||||
const success = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: USER_EMAIL_NEW_SUCCESS,
|
||||
data: {
|
||||
email
|
||||
}
|
||||
type: USER_EMAIL_NEW_STARTED,
|
||||
email
|
||||
});
|
||||
dispatch(doUserFetch());
|
||||
};
|
||||
|
||||
const failure = error => {
|
||||
if (error.response && error.response.status === 409) {
|
||||
const success = () => {
|
||||
dispatch({
|
||||
type: USER_EMAIL_NEW_EXISTS
|
||||
type: USER_EMAIL_NEW_SUCCESS,
|
||||
data: {
|
||||
email
|
||||
}
|
||||
});
|
||||
}
|
||||
dispatch(doUserFetch());
|
||||
resolve();
|
||||
};
|
||||
|
||||
dispatch({
|
||||
type: USER_EMAIL_NEW_FAILURE,
|
||||
data: {
|
||||
error
|
||||
const failure = error => {
|
||||
if (error.response && error.response.status === 409) {
|
||||
dispatch({
|
||||
type: USER_EMAIL_NEW_EXISTS
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Lbryio.call('user', 'signup', {
|
||||
email,
|
||||
...(password ? {
|
||||
password
|
||||
} : {})
|
||||
}, 'post').then(success, failure);
|
||||
dispatch({
|
||||
type: USER_EMAIL_NEW_FAILURE,
|
||||
data: {
|
||||
error
|
||||
}
|
||||
});
|
||||
reject(error);
|
||||
};
|
||||
|
||||
Lbryio.call('user', 'signup', {
|
||||
email,
|
||||
...(password ? {
|
||||
password
|
||||
} : {})
|
||||
}, 'post').then(success, failure);
|
||||
});
|
||||
};
|
||||
}
|
||||
function doUserPasswordReset(email) {
|
||||
|
|
58
dist/bundle.js
vendored
58
dist/bundle.js
vendored
|
@ -5375,41 +5375,45 @@ function doUserSignIn(email, password) {
|
|||
}
|
||||
function doUserSignUp(email, password) {
|
||||
return function (dispatch) {
|
||||
dispatch({
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_STARTED"],
|
||||
email: email
|
||||
});
|
||||
|
||||
var success = function success() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
dispatch({
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_SUCCESS"],
|
||||
data: {
|
||||
email: email
|
||||
}
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_STARTED"],
|
||||
email: email
|
||||
});
|
||||
dispatch(doUserFetch());
|
||||
};
|
||||
|
||||
var failure = function failure(error) {
|
||||
if (error.response && error.response.status === 409) {
|
||||
var success = function success() {
|
||||
dispatch({
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_EXISTS"]
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_SUCCESS"],
|
||||
data: {
|
||||
email: email
|
||||
}
|
||||
});
|
||||
}
|
||||
dispatch(doUserFetch());
|
||||
resolve();
|
||||
};
|
||||
|
||||
dispatch({
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_FAILURE"],
|
||||
data: {
|
||||
error: error
|
||||
var failure = function failure(error) {
|
||||
if (error.response && error.response.status === 409) {
|
||||
dispatch({
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_EXISTS"]
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].call('user', 'signup', _objectSpread({
|
||||
email: email
|
||||
}, password ? {
|
||||
password: password
|
||||
} : {}), 'post').then(success, failure);
|
||||
dispatch({
|
||||
type: constants_action_types__WEBPACK_IMPORTED_MODULE_1__["USER_EMAIL_NEW_FAILURE"],
|
||||
data: {
|
||||
error: error
|
||||
}
|
||||
});
|
||||
reject(error);
|
||||
};
|
||||
|
||||
lbryio__WEBPACK_IMPORTED_MODULE_5__["default"].call('user', 'signup', _objectSpread({
|
||||
email: email
|
||||
}, password ? {
|
||||
password: password
|
||||
} : {}), 'post').then(success, failure);
|
||||
});
|
||||
};
|
||||
}
|
||||
function doUserPasswordReset(email) {
|
||||
|
|
|
@ -390,37 +390,41 @@ export function doUserSignIn(email, password) {
|
|||
}
|
||||
|
||||
export function doUserSignUp(email, password) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_STARTED,
|
||||
email,
|
||||
});
|
||||
|
||||
const success = () => {
|
||||
return dispatch =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_SUCCESS,
|
||||
data: { email },
|
||||
type: ACTIONS.USER_EMAIL_NEW_STARTED,
|
||||
email,
|
||||
});
|
||||
dispatch(doUserFetch());
|
||||
};
|
||||
|
||||
const failure = error => {
|
||||
if (error.response && error.response.status === 409) {
|
||||
const success = () => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_EXISTS,
|
||||
type: ACTIONS.USER_EMAIL_NEW_SUCCESS,
|
||||
data: { email },
|
||||
});
|
||||
}
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_FAILURE,
|
||||
data: { error },
|
||||
});
|
||||
};
|
||||
dispatch(doUserFetch());
|
||||
resolve();
|
||||
};
|
||||
|
||||
Lbryio.call('user', 'signup', { email, ...(password ? { password } : {}) }, 'post').then(
|
||||
success,
|
||||
failure
|
||||
);
|
||||
};
|
||||
const failure = error => {
|
||||
if (error.response && error.response.status === 409) {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_EXISTS,
|
||||
});
|
||||
}
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_FAILURE,
|
||||
data: { error },
|
||||
});
|
||||
|
||||
reject(error);
|
||||
};
|
||||
|
||||
Lbryio.call('user', 'signup', { email, ...(password ? { password } : {}) }, 'post').then(
|
||||
success,
|
||||
failure
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function doUserPasswordReset(email) {
|
||||
|
|
Loading…
Add table
Reference in a new issue