Skip to content

Commit 4bccebf

Browse files
authored
Merge pull request #123 from corgicode/feature/105-on-enter-fns
Closes #105 - Prevents logged in users from entering /signup page
2 parents 8a4caeb + 34c7176 commit 4bccebf

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/containers/about/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class About extends React.Component {
134134
<TeamMember
135135
name="Corginson"
136136
title="Chief Happiness Officer"
137+
description=" "
137138
image={corgiImg}
138139
links={[{href: 'https://twitter.com/codecorgi', className: 'icon-s-twitter'}]}
139140
/>

src/containers/signup/index.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@ import femaleOctocat from '../../assets/images/femalecodertocat.png';
44
import { Link } from 'react-router-dom';
55
import { BACKEND_URL, PROD_URL } from '../../constants';
66
import { Helmet } from 'react-helmet';
7+
import { readEndpoint } from 'redux-json-api';
8+
import PropTypes from 'prop-types';
9+
import { bindActionCreators } from 'redux';
10+
import { connect } from 'react-redux';
11+
import ReactRouterPropTypes from 'react-router-prop-types';
712

813
class Signup extends React.Component {
14+
static propTypes = {
15+
readEndpoint: PropTypes.func.isRequired,
16+
authenticated: PropTypes.bool.isRequired,
17+
history: ReactRouterPropTypes.history.isRequired,
18+
}
19+
20+
componentWillReceiveProps() {
21+
if (this.props.authenticated) {
22+
this.props.history.push('/profile');
23+
}
24+
}
25+
926
render() {
1027
return(
1128
<section id="hero" className="dark-bg img-bg img-bg-soft" style={{ backgroundImage: `url(${blueBg})` }}>
@@ -49,4 +66,15 @@ class Signup extends React.Component {
4966
}
5067
}
5168

52-
export default Signup;
69+
const mapStateToProps = (state) => {
70+
const { profile } = state;
71+
return {
72+
authenticated: profile.authenticated || false,
73+
};
74+
};
75+
76+
const mapDispatchToProps = (dispatch) => bindActionCreators({
77+
readEndpoint,
78+
}, dispatch);
79+
80+
export default connect(mapStateToProps, mapDispatchToProps)(Signup);

0 commit comments

Comments
 (0)