2017-07-19 01:00:13 +02:00
import React from "react" ;
import { BusyMessage } from "component/common" ;
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 ) ) {
return _ _ ( "Welcome to LBRY" ) ;
} 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-07-19 01:00:13 +02:00
return _ _ ( "Confirm Identity" ) ;
} else {
return _ _ ( "Welcome to LBRY" ) ;
}
}
renderMain ( ) {
const { email , isPending , isVerificationCandidate , user } = this . props ;
if ( isPending ) {
return < BusyMessage message = { _ _ ( "Authenticating" ) } / > ;
} else if ( user && ! user . has _verified _email && ! email ) {
return < UserEmailNew / > ;
} else if ( user && ! user . has _verified _email ) {
return < UserEmailVerify / > ;
} else if ( user && ! user . is _identity _verified ) {
return < UserVerify / > ;
} else {
return < span className = "empty" > { _ _ ( "No further steps." ) } < / span > ;
}
}
render ( ) {
2017-07-20 21:03:01 +02:00
const { email , user , isPending } = this . props ;
2017-07-19 01:00:13 +02:00
return (
< main className = "" >
< section className = "card card--form" >
< div className = "card__title-primary" >
< h1 > { this . getTitle ( ) } < / h1 >
< / div >
< div className = "card__content" >
{ ! isPending &&
! email &&
2017-07-20 21:03:01 +02:00
! user . has _verified _email &&
2017-07-19 01:00:13 +02:00
< p >
{ _ _ ( "Create a verified identity and receive LBC rewards." ) }
< / p > }
{ this . renderMain ( ) }
< / div >
< div className = "card__content" >
< div className = "help" >
{ _ _ (
2017-07-25 00:59:26 +02:00
"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."
2017-07-19 01:00:13 +02:00
) }
< / div >
< / div >
< / section >
< / main >
) ;
}
}
export default AuthPage ;