Merge pull request #6 from lbryio/app-updates
updates for desktop app to use lbryinc
This commit is contained in:
commit
c09aa2645e
4 changed files with 530 additions and 912 deletions
1291
dist/bundle.js
vendored
1291
dist/bundle.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -31,6 +31,9 @@ export {
|
|||
doUserPhoneVerifyFailure,
|
||||
doUserPhoneVerify,
|
||||
doFetchAccessToken,
|
||||
doUserResendVerificationEmail,
|
||||
doUserIdentityVerify,
|
||||
doUserInviteNew,
|
||||
} from 'redux/actions/user';
|
||||
|
||||
// reducers
|
||||
|
|
|
@ -70,6 +70,10 @@ Lbryio.getAuthToken = () =>
|
|||
new Promise(resolve => {
|
||||
if (Lbryio.authToken) {
|
||||
resolve(Lbryio.authToken);
|
||||
} else if (Lbryio.overrides.getAuthToken) {
|
||||
Lbryio.overrides.getAuthToken().then(token => {
|
||||
resolve(token);
|
||||
});
|
||||
} else {
|
||||
const { store } = window;
|
||||
if (store) {
|
||||
|
@ -118,6 +122,10 @@ Lbryio.authenticate = () => {
|
|||
}
|
||||
|
||||
return Lbry.status().then(status => {
|
||||
if (Lbryio.overrides.setAuthToken) {
|
||||
return Lbryio.overrides.setAuthToken(status);
|
||||
}
|
||||
|
||||
const { store } = window;
|
||||
if (store) {
|
||||
store.dispatch(doGenerateAuthToken(status.installation_id));
|
||||
|
@ -140,4 +148,11 @@ Lbryio.getStripeToken = () =>
|
|||
? 'pk_test_NoL1JWL7i1ipfhVId5KfDZgo'
|
||||
: 'pk_live_e8M4dRNnCCbmpZzduEUZBgJO';
|
||||
|
||||
// Allow overriding lbryio methods
|
||||
// The desktop app will need to use it for getAuthToken because we use electron's ipcRenderer
|
||||
Lbryio.overrides = {};
|
||||
Lbryio.setOverride = (methodName, newMethod) => {
|
||||
Lbryio.overrides[methodName] = newMethod;
|
||||
};
|
||||
|
||||
export default Lbryio;
|
||||
|
|
|
@ -222,6 +222,38 @@ export function doUserEmailNew(email) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doUserResendVerificationEmail(email) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_VERIFY_RETRY,
|
||||
email,
|
||||
});
|
||||
|
||||
const success = () => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_SUCCESS,
|
||||
data: { email },
|
||||
});
|
||||
dispatch(doUserFetch());
|
||||
};
|
||||
|
||||
const failure = error => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_EMAIL_NEW_FAILURE,
|
||||
data: { error },
|
||||
});
|
||||
};
|
||||
|
||||
Lbryio.call('user_email', 'resend_token', { email }, 'post')
|
||||
.catch(error => {
|
||||
if (error.response && error.response.status === 409) {
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
.then(success, failure);
|
||||
};
|
||||
}
|
||||
|
||||
export function doUserEmailVerifyFailure(error) {
|
||||
return {
|
||||
type: ACTIONS.USER_EMAIL_VERIFY_FAILURE,
|
||||
|
@ -274,3 +306,62 @@ export function doFetchAccessToken() {
|
|||
Lbryio.getAuthToken().then(success);
|
||||
};
|
||||
}
|
||||
|
||||
export function doUserIdentityVerify(stripeToken) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_IDENTITY_VERIFY_STARTED,
|
||||
token: stripeToken,
|
||||
});
|
||||
|
||||
Lbryio.call('user', 'verify_identity', { stripe_token: stripeToken }, 'post')
|
||||
.then(user => {
|
||||
if (user.is_identity_verified) {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_IDENTITY_VERIFY_SUCCESS,
|
||||
data: { user },
|
||||
});
|
||||
dispatch(doClaimRewardType(rewards.TYPE_NEW_USER));
|
||||
} else {
|
||||
throw new Error('Your identity is still not verified. This should not happen.'); // shouldn't happen
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_IDENTITY_VERIFY_FAILURE,
|
||||
data: { error: error.toString() },
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doUserInviteNew(email) {
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_INVITE_NEW_STARTED,
|
||||
});
|
||||
|
||||
Lbryio.call('user', 'invite', { email }, 'post')
|
||||
.then(() => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_INVITE_NEW_SUCCESS,
|
||||
data: { email },
|
||||
});
|
||||
|
||||
dispatch(
|
||||
doNotify({
|
||||
displayType: ['snackbar'],
|
||||
message: __('Invite sent to %s', email),
|
||||
})
|
||||
);
|
||||
|
||||
dispatch(doFetchInviteStatus());
|
||||
})
|
||||
.catch(error => {
|
||||
dispatch({
|
||||
type: ACTIONS.USER_INVITE_NEW_FAILURE,
|
||||
data: { error },
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue