auth flow fixes

This commit is contained in:
Jeremy Kauffman 2017-07-24 18:59:26 -04:00
parent 9bb618e3af
commit 29553bc391
10 changed files with 129 additions and 97 deletions

View file

@ -1,4 +1,5 @@
import * as types from "constants/action_types";
import * as modals from "constants/modal_types";
import lbryio from "lbryio";
import rewards from "rewards";
import { selectRewardsByType } from "selectors/rewards";
@ -58,6 +59,12 @@ export function doClaimReward(reward, saveError = false) {
reward,
},
});
if (reward.reward_type == rewards.TYPE_NEW_USER) {
dispatch({
type: types.OPEN_MODAL,
data: { modal: modals.FIRST_REWARD },
});
}
};
const failure = error => {

View file

@ -1,8 +1,9 @@
import * as types from "constants/action_types";
import lbryio from "lbryio";
import { setLocal } from "utils";
import { doRewardList } from "actions/rewards";
import { doRewardList, doClaimRewardType } from "actions/rewards";
import { selectEmailToVerify, selectUser } from "selectors/user";
import rewards from "rewards";
export function doAuthenticate() {
return function(dispatch, getState) {
@ -152,6 +153,7 @@ export function doUserIdentityVerify(stripeToken) {
type: types.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."
@ -159,18 +161,6 @@ export function doUserIdentityVerify(stripeToken) {
}
})
.catch(error => {
// let user = selectUser(getState());
// user.is_identity_verified = true;
// if (user.is_identity_verified) {
// dispatch({
// type: types.USER_IDENTITY_VERIFY_SUCCESS,
// data: { user },
// });
// } else {
// throw new Error(
// "Your identity is still not verified. This should not happen."
// ); //shouldn't happen
// }
dispatch({
type: types.USER_IDENTITY_VERIFY_FAILURE,
data: { error: error.toString() },

View file

@ -6,6 +6,7 @@ import ModalDownloading from "component/modalDownloading";
import ModalInsufficientCredits from "component/modalInsufficientCredits";
import ModalUpgrade from "component/modalUpgrade";
import ModalWelcome from "component/modalWelcome";
import ModalFirstReward from "component/modalFirstReward";
import lbry from "lbry";
import * as modals from "constants/modal_types";
@ -72,6 +73,7 @@ class App extends React.PureComponent {
{modal == modals.ERROR && <ModalError />}
{modal == modals.INSUFFICIENT_CREDITS && <ModalInsufficientCredits />}
{modal == modals.WELCOME && <ModalWelcome />}
{modal == modals.FIRST_REWARD && <ModalFirstReward />}
</div>
);
}

View file

@ -0,0 +1,20 @@
import React from "react";
import rewards from "rewards";
import { connect } from "react-redux";
import { doCloseModal } from "actions/app";
import { makeSelectRewardByType } from "selectors/rewards";
import ModalFirstReward from "./view";
const select = (state, props) => {
const selectReward = makeSelectRewardByType();
return {
reward: selectReward(state, { reward_type: rewards.TYPE_NEW_USER }),
};
};
const perform = dispatch => ({
closeModal: () => dispatch(doCloseModal()),
});
export default connect(select, perform)(ModalFirstReward);

View file

@ -0,0 +1,50 @@
import React from "react";
import { Modal } from "component/modal";
import { CreditAmount } from "component/common";
class ModalFirstReward extends React.PureComponent {
render() {
const { closeModal, reward } = this.props;
return (
<Modal
type="alert"
overlayClassName="modal-overlay modal-overlay--clear"
isOpen={true}
contentLabel={__("Welcome to LBRY")}
onConfirmed={closeModal}
>
<section>
<h3 className="modal__header">{__("About Your Reward")}</h3>
<p>
{__("You earned a reward of")}
{" "}<CreditAmount amount={reward.reward_amount} label={false} />
{" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>.
</p>
<p>
{__(
"This reward will show in your Wallet momentarily, shown in the top right, probably while you are reading this message."
)}
</p>
<p>
{__(
"LBC is used to compensate creators, to publish, and to have say in how the network works."
)}
</p>
<p>
{__(
"No need to understand it all just yet! Try watching or downloading something next."
)}
</p>
<p>
{__(
"Finally, pleaseh know that LBRY is an early beta and that it earns the name."
)}
</p>
</section>
</Modal>
);
}
}
export default ModalFirstReward;

View file

@ -15,7 +15,6 @@ const select = (state, props) => {
selectReward = makeSelectRewardByType();
return {
hasClaimed: selectHasClaimed(state, { reward_type: rewards.TYPE_NEW_USER }),
isRewardApproved: selectUserIsRewardApproved(state),
reward: selectReward(state, { reward_type: rewards.TYPE_NEW_USER }),
};

View file

@ -6,16 +6,10 @@ import RewardLink from "component/rewardLink";
class ModalWelcome extends React.PureComponent {
render() {
const {
closeModal,
hasClaimed,
isRewardApproved,
reward,
verifyAccount,
} = this.props;
const { closeModal, isRewardApproved, reward, verifyAccount } = this.props;
return !hasClaimed
? <Modal type="custom" isOpen={true} contentLabel="Welcome to LBRY">
return (
<Modal type="custom" isOpen={true} contentLabel="Welcome to LBRY">
<section>
<h3 className="modal__header">{__("Welcome to LBRY.")}</h3>
<p>
@ -46,47 +40,11 @@ class ModalWelcome extends React.PureComponent {
onClick={verifyAccount}
label={__("Get Welcome Credits")}
/>}
{!isRewardApproved &&
<Link button="alt" onClick={closeModal} label={__("Skip")} />}
<Link button="alt" onClick={closeModal} label={__("Skip")} />
</div>
</section>
</Modal>
: <Modal
type="alert"
overlayClassName="modal-overlay modal-overlay--clear"
isOpen={true}
contentLabel={__("Welcome to LBRY")}
onConfirmed={closeModal}
>
<section>
<h3 className="modal__header">{__("About Your Reward")}</h3>
<p>
{__("You earned a reward of")}
{" "}<CreditAmount amount={reward.reward_amount} label={false} />
{" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>.
</p>
<p>
{__(
"This reward will show in your Wallet momentarily, probably while you are reading this message."
)}
</p>
<p>
{__(
"LBC is used to compensate creators, to publish, and to have say in how the network works."
)}
</p>
<p>
{__(
"No need to understand it all just yet! Try watching or downloading something next."
)}
</p>
<p>
{__(
"Finally, know that LBRY is an early beta and that it earns the name."
)}
</p>
</section>
</Modal>;
);
}
}

View file

@ -5,3 +5,4 @@ export const ERROR = "error";
export const INSUFFICIENT_CREDITS = "insufficient_credits";
export const UPGRADE = "upgrade";
export const WELCOME = "welcome";
export const FIRST_REWARD = "first_reward";

View file

@ -76,7 +76,7 @@ export class AuthPage extends React.PureComponent {
<div className="card__content">
<div className="help">
{__(
"This information is disclosed only to LBRY, Inc. and not to the LBRY network. It is collected to provide communication and prevent abuse."
"This information is disclosed only to LBRY, Inc. and not to the LBRY network. It is optional and only collected to provide communication and prevent abuse. You may use LBRY without providing this information."
)}
</div>
</div>

View file

@ -97,11 +97,16 @@ class RewardsPage extends React.PureComponent {
{" "}
{__("This can take anywhere from several minutes to several days.")}
</p>
<p>
{__("You will receive an email when this process is complete.")}
{__(
"We apologize for this inconvenience, but have added this additional step to prevent fraud."
)}
</p>
<p>
{__("Please enjoy free content in the meantime!")}
{__("You will receive an email when this process is complete.") +
" " +
__("Please enjoy free content in the meantime!")}
</p>
<p>
<Link