Fix phone verification + claim first reward

This ensures that a newly verified user, via phone verification, automatically claims the new user reward.
This commit is contained in:
Thomas Zarebczan 2018-06-18 17:09:21 -04:00
parent 70ba685d68
commit 4c23f4e105
2 changed files with 11 additions and 10 deletions

View file

@ -1,6 +1,6 @@
import * as ACTIONS from 'constants/action_types';
import Lbryio from 'lbryio';
import { Lbry, doNotify, MODALS } from 'lbry-redux';
import { Lbry, doNotify, MODALS, doHideNotification } from 'lbry-redux';
import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
import {
selectEmailToVerify,
@ -163,13 +163,15 @@ export function doUserPhoneVerify(verificationCode) {
},
'post'
)
.then(() => {
.then(user => {
if (user.is_identity_verified) {
dispatch({
type: ACTIONS.USER_PHONE_VERIFY_SUCCESS,
data: { phone_number: phoneNumber },
data: { user },
});
dispatch(doUserFetch());
dispatch(doHideNotification());
dispatch(doClaimRewardType(rewards.TYPE_NEW_USER));
}
})
.catch(error => dispatch(doUserPhoneVerifyFailure(error)));
};

View file

@ -88,13 +88,12 @@ reducers[ACTIONS.USER_PHONE_VERIFY_STARTED] = state =>
phoneVerifyErrorMessage: '',
});
reducers[ACTIONS.USER_PHONE_VERIFY_SUCCESS] = (state, action) => {
reducers[ACTIONS.USER_PHONE_VERIFY_SUCCESS] = (state, action) =>
Object.assign({}, state, {
phoneToVerify: '',
phoneVerifyIsPending: false,
user: action.data.user,
});
};
reducers[ACTIONS.USER_PHONE_VERIFY_FAILURE] = (state, action) =>
Object.assign({}, state, {