2017-07-19 01:00:13 +02:00
|
|
|
import React from "react";
|
|
|
|
import { BusyMessage } from "component/common";
|
2017-07-29 18:58:31 +02:00
|
|
|
import Link from "component/link";
|
2017-07-19 01:00:13 +02:00
|
|
|
import UserEmailNew from "component/userEmailNew";
|
|
|
|
import UserEmailVerify from "component/userEmailVerify";
|
|
|
|
import UserVerify from "component/userVerify";
|
|
|
|
|
|
|
|
export class AuthPage extends React.PureComponent {
|
|
|
|
componentWillMount() {
|
|
|
|
this.navigateIfAuthenticated(this.props);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
this.navigateIfAuthenticated(nextProps);
|
|
|
|
}
|
|
|
|
|
|
|
|
navigateIfAuthenticated(props) {
|
|
|
|
const { isPending, user } = props;
|
|
|
|
if (
|
|
|
|
!isPending &&
|
|
|
|
user &&
|
|
|
|
user.has_verified_email &&
|
2017-07-25 20:34:28 +02:00
|
|
|
(user.is_reward_approved || user.is_identity_verified)
|
2017-07-19 01:00:13 +02:00
|
|
|
) {
|
2017-07-19 17:09:40 +02:00
|
|
|
props.navigate(props.pathAfterAuth);
|
2017-07-19 01:00:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getTitle() {
|
|
|
|
const { email, isPending, isVerificationCandidate, user } = this.props;
|
|
|
|
|
|
|
|
if (isPending || (user && !user.has_verified_email && !email)) {
|
2017-08-26 05:21:26 +02:00
|
|
|
return __("Human Proofing");
|
2017-07-19 01:00:13 +02:00
|
|
|
} else if (user && !user.has_verified_email) {
|
|
|
|
return __("Confirm Email");
|
2017-07-25 20:34:28 +02:00
|
|
|
} else if (user && !user.is_identity_verified && !user.is_reward_approved) {
|
2017-08-26 05:21:26 +02:00
|
|
|
return __("Final Verification");
|
2017-07-19 01:00:13 +02:00
|
|
|
} else {
|
|
|
|
return __("Welcome to LBRY");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
renderMain() {
|
|
|
|
const { email, isPending, isVerificationCandidate, user } = this.props;
|
|
|
|
|
|
|
|
if (isPending) {
|
2017-08-26 05:21:26 +02:00
|
|
|
return [<BusyMessage message={__("Authenticating")} />, true];
|
2017-07-19 01:00:13 +02:00
|
|
|
} else if (user && !user.has_verified_email && !email) {
|
2017-08-26 05:21:26 +02:00
|
|
|
return [<UserEmailNew />, true];
|
2017-07-19 01:00:13 +02:00
|
|
|
} else if (user && !user.has_verified_email) {
|
2017-08-26 05:21:26 +02:00
|
|
|
return [<UserEmailVerify />, true];
|
2017-07-19 01:00:13 +02:00
|
|
|
} else if (user && !user.is_identity_verified) {
|
2017-08-26 05:21:26 +02:00
|
|
|
return [<UserVerify />, false];
|
2017-07-19 01:00:13 +02:00
|
|
|
} else {
|
2017-08-26 05:21:26 +02:00
|
|
|
return [<span className="empty">{__("No further steps.")}</span>, true];
|
2017-07-19 01:00:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-07-29 18:58:31 +02:00
|
|
|
const { email, user, isPending, navigate } = this.props;
|
2017-08-26 05:21:26 +02:00
|
|
|
const [innerContent, useTemplate] = this.renderMain();
|
2017-07-19 01:00:13 +02:00
|
|
|
|
2017-11-24 15:31:05 +01:00
|
|
|
return useTemplate ? (
|
|
|
|
<main>
|
|
|
|
<section className="card card--form">
|
|
|
|
<div className="card__title-primary">
|
|
|
|
<h1>{this.getTitle()}</h1>
|
|
|
|
</div>
|
|
|
|
<div className="card__content">{innerContent}</div>
|
|
|
|
<div className="card__content">
|
|
|
|
<div className="help">
|
|
|
|
{__(
|
|
|
|
"This information is disclosed only to LBRY, Inc. and not to the LBRY network. It is only required to earn LBRY rewards."
|
|
|
|
) + " "}
|
|
|
|
<Link
|
|
|
|
onClick={() => navigate("/discover")}
|
|
|
|
label={__("Return home")}
|
|
|
|
/>.
|
2017-08-26 05:21:26 +02:00
|
|
|
</div>
|
2017-11-24 15:31:05 +01:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</main>
|
|
|
|
) : (
|
|
|
|
innerContent
|
|
|
|
);
|
2017-07-19 01:00:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AuthPage;
|