mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Inject isLoggedIn through withCurrentUser
Makes checking for logged in status less error prone than always using `currentUser.email` or `currentUser.username`.
This commit is contained in:
parent
b99782455e
commit
b5eda1cdd2
@ -23,8 +23,6 @@ import Property from '../ascribe_forms/property';
|
|||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
import { currentUserShape } from '../prop_types';
|
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
|
||||||
@ -37,14 +35,16 @@ import { withCurrentUser } from '../../utils/react_utils';
|
|||||||
*/
|
*/
|
||||||
const Edition = React.createClass({
|
const Edition = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
edition: React.PropTypes.object.isRequired,
|
edition: React.PropTypes.object.isRequired,
|
||||||
whitelabel: React.PropTypes.object.isRequired,
|
whitelabel: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
actionPanelButtonListType: React.PropTypes.func,
|
actionPanelButtonListType: React.PropTypes.func,
|
||||||
coaError: React.PropTypes.object,
|
coaError: React.PropTypes.object,
|
||||||
furtherDetailsType: React.PropTypes.func,
|
furtherDetailsType: React.PropTypes.func,
|
||||||
loadEdition: React.PropTypes.func
|
loadEdition: React.PropTypes.func,
|
||||||
|
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired // eslint-disable-line react/sort-prop-types
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
@ -54,13 +54,15 @@ const Edition = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { actionPanelButtonListType,
|
const {
|
||||||
coaError,
|
actionPanelButtonListType,
|
||||||
currentUser,
|
coaError,
|
||||||
edition,
|
edition,
|
||||||
furtherDetailsType: FurtherDetailsType,
|
isLoggedIn,
|
||||||
loadEdition,
|
loadEdition,
|
||||||
whitelabel } = this.props;
|
whitelabel,
|
||||||
|
furtherDetailsType: FurtherDetailsType
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
@ -113,7 +115,7 @@ const Edition = React.createClass({
|
|||||||
|
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Notes')}
|
title={getLangText('Notes')}
|
||||||
show={!!(currentUser.username || edition.acl.acl_edit || edition.public_note)}>
|
show={!!(isLoggedIn || edition.acl.acl_edit || edition.public_note)}>
|
||||||
<Note
|
<Note
|
||||||
id={() => {return {'bitcoin_id': edition.bitcoin_id}; }}
|
id={() => {return {'bitcoin_id': edition.bitcoin_id}; }}
|
||||||
label={getLangText('Personal note (private)')}
|
label={getLangText('Personal note (private)')}
|
||||||
@ -154,12 +156,14 @@ const Edition = React.createClass({
|
|||||||
|
|
||||||
let EditionSummary = withCurrentUser(React.createClass({
|
let EditionSummary = withCurrentUser(React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
edition: React.PropTypes.object.isRequired,
|
edition: React.PropTypes.object.isRequired,
|
||||||
whitelabel: React.PropTypes.object.isRequired,
|
whitelabel: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
actionPanelButtonListType: React.PropTypes.func,
|
actionPanelButtonListType: React.PropTypes.func,
|
||||||
handleSuccess: React.PropTypes.func
|
handleSuccess: React.PropTypes.func,
|
||||||
|
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
},
|
},
|
||||||
|
|
||||||
getStatus() {
|
getStatus() {
|
||||||
@ -173,7 +177,13 @@ let EditionSummary = withCurrentUser(React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { actionPanelButtonListType, currentUser, edition, handleSuccess, whitelabel } = this.props;
|
const {
|
||||||
|
actionPanelButtonListType,
|
||||||
|
edition,
|
||||||
|
handleSuccess,
|
||||||
|
isLoggedIn,
|
||||||
|
whitelabel
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-detail-header">
|
<div className="ascribe-detail-header">
|
||||||
@ -197,7 +207,7 @@ let EditionSummary = withCurrentUser(React.createClass({
|
|||||||
no more than 1 key, we're hiding the `DetailProperty` actions as otherwise
|
no more than 1 key, we're hiding the `DetailProperty` actions as otherwise
|
||||||
`AclInformation` would show up
|
`AclInformation` would show up
|
||||||
*/}
|
*/}
|
||||||
<AclProxy show={currentUser.email && Object.keys(edition.acl).length > 1}>
|
<AclProxy show={isLoggedIn && Object.keys(edition.acl).length > 1}>
|
||||||
<DetailProperty
|
<DetailProperty
|
||||||
label={getLangText('ACTIONS')}
|
label={getLangText('ACTIONS')}
|
||||||
className="hidden-print">
|
className="hidden-print">
|
||||||
|
@ -9,14 +9,11 @@ import Form from '../ascribe_forms/form';
|
|||||||
import Property from '../ascribe_forms/property';
|
import Property from '../ascribe_forms/property';
|
||||||
import InputTextAreaToggable from '../ascribe_forms/input_textarea_toggable';
|
import InputTextAreaToggable from '../ascribe_forms/input_textarea_toggable';
|
||||||
|
|
||||||
import { currentUserShape } from '../prop_types';
|
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../utils/react_utils';
|
import { withCurrentUser } from '../../utils/react_utils';
|
||||||
|
|
||||||
let Note = React.createClass({
|
let Note = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
id: React.PropTypes.func.isRequired,
|
id: React.PropTypes.func.isRequired,
|
||||||
url: React.PropTypes.string.isRequired,
|
url: React.PropTypes.string.isRequired,
|
||||||
|
|
||||||
@ -25,7 +22,10 @@ let Note = React.createClass({
|
|||||||
label: React.PropTypes.string,
|
label: React.PropTypes.string,
|
||||||
placeholder: React.PropTypes.string,
|
placeholder: React.PropTypes.string,
|
||||||
show: React.PropTypes.bool,
|
show: React.PropTypes.bool,
|
||||||
successMessage: React.PropTypes.string
|
successMessage: React.PropTypes.string,
|
||||||
|
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired // eslint-disable-line react/sort-prop-types
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
@ -43,9 +43,18 @@ let Note = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser, defaultValue, editable, id, label, placeholder, show, url } = this.props;
|
const {
|
||||||
|
defaultValue,
|
||||||
|
editable,
|
||||||
|
id,
|
||||||
|
isLoggedIn,
|
||||||
|
label,
|
||||||
|
placeholder,
|
||||||
|
show,
|
||||||
|
url
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
if ((currentUser.username && editable || !editable) && show) {
|
if ((isLoggedIn && editable || !editable) && show) {
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
url={url}
|
url={url}
|
||||||
|
@ -38,8 +38,6 @@ import ListRequestActions from '../ascribe_forms/list_form_request_actions';
|
|||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
import AscribeSpinner from '../ascribe_spinner';
|
import AscribeSpinner from '../ascribe_spinner';
|
||||||
|
|
||||||
import { currentUserShape } from '../prop_types';
|
|
||||||
|
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../utils/dom_utils';
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
@ -52,11 +50,13 @@ import { withCurrentUser } from '../../utils/react_utils';
|
|||||||
*/
|
*/
|
||||||
const PieceContainer = React.createClass({
|
const PieceContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
router: React.PropTypes.object.isRequired,
|
router: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
furtherDetailsType: React.PropTypes.func,
|
furtherDetailsType: React.PropTypes.func,
|
||||||
|
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
|
|
||||||
// Provided from AscribeApp
|
// Provided from AscribeApp
|
||||||
whitelabel: React.PropTypes.object,
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ const PieceContainer = React.createClass({
|
|||||||
|
|
||||||
getActions() {
|
getActions() {
|
||||||
const { piece } = this.state;
|
const { piece } = this.state;
|
||||||
const { currentUser } = this.props;
|
const { isLoggedIn } = this.props;
|
||||||
|
|
||||||
if (piece.notifications && piece.notifications.length > 0) {
|
if (piece.notifications && piece.notifications.length > 0) {
|
||||||
return (
|
return (
|
||||||
@ -224,7 +224,7 @@ const PieceContainer = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<AclProxy
|
<AclProxy
|
||||||
show={currentUser.email && Object.keys(piece.acl).length > 1}>
|
show={isLoggedIn && Object.keys(piece.acl).length > 1}>
|
||||||
{/*
|
{/*
|
||||||
`acl_view` is always available in `edition.acl`, therefore if it has
|
`acl_view` is always available in `edition.acl`, therefore if it has
|
||||||
no more than 1 key, we're hiding the `DetailProperty` actions as otherwise
|
no more than 1 key, we're hiding the `DetailProperty` actions as otherwise
|
||||||
@ -260,7 +260,7 @@ const PieceContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { furtherDetailsType: FurtherDetailsType } = this.props;
|
const { isLoggedIn, furtherDetailsType: FurtherDetailsType } = this.props;
|
||||||
const { piece } = this.state;
|
const { piece } = this.state;
|
||||||
|
|
||||||
if (piece.id) {
|
if (piece.id) {
|
||||||
@ -299,7 +299,7 @@ const PieceContainer = React.createClass({
|
|||||||
</CollapsibleParagraph>
|
</CollapsibleParagraph>
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Notes')}
|
title={getLangText('Notes')}
|
||||||
show={!!(currentUser.username || piece.acl.acl_edit || piece.public_note)}>
|
show={!!(isLoggedIn || piece.acl.acl_edit || piece.public_note)}>
|
||||||
<Note
|
<Note
|
||||||
id={this.getId}
|
id={this.getId}
|
||||||
label={getLangText('Personal note (private)')}
|
label={getLangText('Personal note (private)')}
|
||||||
|
@ -23,6 +23,7 @@ const CopyrightAssociationForm = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
// Injected through HOCs
|
// Injected through HOCs
|
||||||
currentUser: currentUserShape.isRequired,
|
currentUser: currentUserShape.isRequired,
|
||||||
|
isLoggedIn: bool.isRequired
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSubmitSuccess() {
|
handleSubmitSuccess() {
|
||||||
@ -35,7 +36,7 @@ const CopyrightAssociationForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser } = this.props;
|
const { currentUser, isLoggedIn } = this.props;
|
||||||
const selectDefaultValue = ' -- ' + getLangText('select an association') + ' -- ';
|
const selectDefaultValue = ' -- ' + getLangText('select an association') + ' -- ';
|
||||||
|
|
||||||
let selectedState = selectDefaultValue;
|
let selectedState = selectDefaultValue;
|
||||||
@ -45,7 +46,7 @@ const CopyrightAssociationForm = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentUser.email) {
|
if (isLoggedIn) {
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
ref='form'
|
ref='form'
|
||||||
|
@ -10,7 +10,6 @@ import BitcoinWalletSettings from './bitcoin_wallet_settings';
|
|||||||
import WebhookSettings from './webhook_settings';
|
import WebhookSettings from './webhook_settings';
|
||||||
|
|
||||||
import AclProxy from '../acl_proxy';
|
import AclProxy from '../acl_proxy';
|
||||||
import { currentUserShape } from '../prop_types';
|
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../utils/dom_utils';
|
import { setDocumentTitle } from '../../utils/dom_utils';
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
@ -19,13 +18,14 @@ import { withCurrentUser } from '../../utils/react_utils';
|
|||||||
|
|
||||||
let SettingsContainer = React.createClass({
|
let SettingsContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
|
|
||||||
children: React.PropTypes.oneOfType([
|
children: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||||
React.PropTypes.element
|
React.PropTypes.element
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
|
|
||||||
// Provided from AscribeApp
|
// Provided from AscribeApp
|
||||||
whitelabel: React.PropTypes.object.isRequired,
|
whitelabel: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
@ -38,11 +38,11 @@ let SettingsContainer = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children, currentUser, whitelabel } = this.props;
|
const { children, isLoggedIn, whitelabel } = this.props;
|
||||||
|
|
||||||
setDocumentTitle(getLangText('Account settings'));
|
setDocumentTitle(getLangText('Account settings'));
|
||||||
|
|
||||||
if (currentUser.username) {
|
if (isLoggedIn) {
|
||||||
return (
|
return (
|
||||||
<div className="settings-container">
|
<div className="settings-container">
|
||||||
<AccountSettings
|
<AccountSettings
|
||||||
|
@ -31,6 +31,7 @@ let Header = React.createClass({
|
|||||||
|
|
||||||
// Injected through HOCs
|
// Injected through HOCs
|
||||||
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
|
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -110,14 +111,14 @@ let Header = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser, routes, whitelabel } = this.props;
|
const { currentUser, isLoggedIn, routes, whitelabel } = this.props;
|
||||||
const { unfilteredPieceListCount } = this.state;
|
const { unfilteredPieceListCount } = this.state;
|
||||||
|
|
||||||
let account;
|
let account;
|
||||||
let signup;
|
let signup;
|
||||||
let navRoutesLinks;
|
let navRoutesLinks;
|
||||||
|
|
||||||
if (currentUser.username) {
|
if (isLoggedIn) {
|
||||||
account = (
|
account = (
|
||||||
<DropdownButton
|
<DropdownButton
|
||||||
ref='dropdownbutton'
|
ref='dropdownbutton'
|
||||||
|
@ -20,6 +20,7 @@ let HeaderNotifications = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
// Injected through HOCs
|
// Injected through HOCs
|
||||||
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
|
currentUser: currentUserShape.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired // eslint-disable-line react/sort-prop-types
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -29,7 +30,7 @@ let HeaderNotifications = React.createClass({
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
NotificationStore.listen(this.onChange);
|
NotificationStore.listen(this.onChange);
|
||||||
|
|
||||||
if (this.props.currentUser.email) {
|
if (this.props.isLoggedIn) {
|
||||||
this.refreshNotifications();
|
this.refreshNotifications();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -13,7 +13,6 @@ import Note from '../../../../ascribe_detail/note';
|
|||||||
import Piece from '../../../../../components/ascribe_detail/piece';
|
import Piece from '../../../../../components/ascribe_detail/piece';
|
||||||
|
|
||||||
import AscribeSpinner from '../../../../ascribe_spinner';
|
import AscribeSpinner from '../../../../ascribe_spinner';
|
||||||
import { currentUserShape } from '../../../../prop_types';
|
|
||||||
|
|
||||||
import ApiUrls from '../../../../../constants/api_urls';
|
import ApiUrls from '../../../../../constants/api_urls';
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ import { withCurrentUser } from '../../../../../utils/react_utils';
|
|||||||
let WalletPieceContainer = React.createClass({
|
let WalletPieceContainer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
piece: React.PropTypes.object.isRequired,
|
piece: React.PropTypes.object.isRequired,
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
handleDeleteSuccess: React.PropTypes.func.isRequired,
|
handleDeleteSuccess: React.PropTypes.func.isRequired,
|
||||||
loadPiece: React.PropTypes.func.isRequired,
|
loadPiece: React.PropTypes.func.isRequired,
|
||||||
submitButtonType: React.PropTypes.func.isRequired,
|
submitButtonType: React.PropTypes.func.isRequired,
|
||||||
@ -32,13 +30,16 @@ let WalletPieceContainer = React.createClass({
|
|||||||
children: React.PropTypes.oneOfType([
|
children: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.object,
|
React.PropTypes.object,
|
||||||
React.PropTypes.array
|
React.PropTypes.array
|
||||||
])
|
]),
|
||||||
|
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired // eslint-disable-line react/sort-prop-types
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children,
|
const { children,
|
||||||
currentUser,
|
|
||||||
handleDeleteSuccess,
|
handleDeleteSuccess,
|
||||||
|
isLoggedIn,
|
||||||
loadPiece,
|
loadPiece,
|
||||||
piece,
|
piece,
|
||||||
submitButtonType } = this.props;
|
submitButtonType } = this.props;
|
||||||
@ -76,7 +77,7 @@ let WalletPieceContainer = React.createClass({
|
|||||||
</CollapsibleParagraph>
|
</CollapsibleParagraph>
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Notes')}
|
title={getLangText('Notes')}
|
||||||
show={!!(currentUser.username || piece.public_note)}>
|
show={!!(isLoggedIn || piece.public_note)}>
|
||||||
<Note
|
<Note
|
||||||
id={() => {return {'id': piece.id}; }}
|
id={() => {return {'id': piece.id}; }}
|
||||||
label={getLangText('Personal note (private)')}
|
label={getLangText('Personal note (private)')}
|
||||||
|
@ -6,8 +6,6 @@ import Button from 'react-bootstrap/lib/Button';
|
|||||||
|
|
||||||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
||||||
|
|
||||||
import { currentUserShape } from '../../../../prop_types';
|
|
||||||
|
|
||||||
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
import { setDocumentTitle } from '../../../../../utils/dom_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
import { withCurrentUser } from '../../../../../utils/react_utils';
|
import { withCurrentUser } from '../../../../../utils/react_utils';
|
||||||
@ -15,8 +13,10 @@ import { withCurrentUser } from '../../../../../utils/react_utils';
|
|||||||
|
|
||||||
let IkonotvLanding = React.createClass({
|
let IkonotvLanding = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
// Injected through HOCs
|
||||||
|
isLoggedIn: React.PropTypes.bool.isRequired, // eslint-disable-line react/sort-prop-types
|
||||||
|
|
||||||
// Provided from WalletApp
|
// Provided from WalletApp
|
||||||
currentUser: currentUserShape.isRequired,
|
|
||||||
whitelabel: React.PropTypes.object,
|
whitelabel: React.PropTypes.object,
|
||||||
|
|
||||||
// Provided from router
|
// Provided from router
|
||||||
@ -24,10 +24,10 @@ let IkonotvLanding = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getEnterButton() {
|
getEnterButton() {
|
||||||
const { currentUser, location } = this.props;
|
const { isLoggedIn, location } = this.props;
|
||||||
let redirect = '/login';
|
let redirect = '/login';
|
||||||
|
|
||||||
if (currentUser.email) {
|
if (isLoggedIn) {
|
||||||
redirect = '/collection';
|
redirect = '/collection';
|
||||||
} else if (location.query.redirect) {
|
} else if (location.query.redirect) {
|
||||||
redirect = '/' + location.query.redirect;
|
redirect = '/' + location.query.redirect;
|
||||||
|
@ -12,9 +12,10 @@ export function getDisplayName(WrappedComponent) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to react-router's `withRouter`, this injects the `currentUser` from the Component's
|
* Similar to react-router's `withRouter`, this injects the `currentUser` from the Component's
|
||||||
* context into the Component as a prop.
|
* context into the Component as a prop. It also injects whether the user's logged in or not as
|
||||||
|
* `isLoggedIn`.
|
||||||
*
|
*
|
||||||
* @param {Component} Component Component to inject `context.currentUser` into
|
* @param {Component} Component Component to inject `context.currentUser` and `isLoggedIn` into
|
||||||
* @return {Component} Wrapped component
|
* @return {Component} Wrapped component
|
||||||
*/
|
*/
|
||||||
export function withCurrentUser(Component) {
|
export function withCurrentUser(Component) {
|
||||||
@ -23,7 +24,7 @@ export function withCurrentUser(Component) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const WithCurrentUser = (props, { currentUser }) => (
|
const WithCurrentUser = (props, { currentUser }) => (
|
||||||
<Component {...props} currentUser={currentUser} />
|
<Component {...props} currentUser={currentUser} isLoggedIn={!!currentUser.email} />
|
||||||
);
|
);
|
||||||
|
|
||||||
WithCurrentUser.displayName = `WithCurrentUser(${getDisplayName(Component)})`;
|
WithCurrentUser.displayName = `WithCurrentUser(${getDisplayName(Component)})`;
|
||||||
|
Loading…
Reference in New Issue
Block a user