Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d573f31

Browse files
committed
update to constant routes, use dynamic authorizaton rule
1 parent dfe89e0 commit d573f31

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

‎src/components/Account/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const mapStateToProps = (state) => ({
1717
authUser: state.sessionState.authUser,
1818
});
1919

20+
const authCondition = (authUser) => !!authUser;
21+
2022
export default compose(
21-
withAuthorization(true),
23+
withAuthorization(authCondition),
2224
connect(mapStateToProps)
2325
)(AccountPage);

‎src/components/Home/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const mapDispatchToProps = (dispatch) => ({
4949
onSetUsers: (users) => dispatch({ type: 'USERS_SET', users }),
5050
});
5151

52+
const authCondition = (authUser) => !!authUser;
53+
5254
export default compose(
53-
withAuthorization(true),
55+
withAuthorization(authCondition),
5456
connect(mapStateToProps, mapDispatchToProps)
5557
)(HomePage);

‎src/components/PasswordForget/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
22
import { Link } from 'react-router-dom';
33

44
import { auth } from '../../firebase';
5+
import * as routes from '../../constants/routes';
56

67
const PasswordForgetPage = () =>
78
<div>
@@ -67,7 +68,7 @@ class PasswordForgetForm extends Component {
6768

6869
const PasswordForgetLink = () =>
6970
<p>
70-
<Link to="/pw-forget">Forgot Password?</Link>
71+
<Link to={routes.PASSWORD_FORGET}>Forgot Password?</Link>
7172
</p>
7273

7374
export default PasswordForgetPage;

‎src/components/Session/withAuthorization.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { withRouter } from 'react-router-dom';
66
import { firebase } from '../../firebase';
77
import * as routes from '../../constants/routes';
88

9-
const withAuthorization = (needsAuthorization) => (Component) => {
9+
const withAuthorization = (condition) => (Component) => {
1010
class WithAuthorization extends React.Component {
1111
componentDidMount() {
1212
firebase.auth.onAuthStateChanged(authUser => {
13-
if (!authUser&&needsAuthorization) {
13+
if (!condition(authUser)) {
1414
this.props.history.push(routes.SIGN_IN);
1515
}
1616
});

‎src/components/SignUp/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class SignUpForm extends Component {
7676
const isInvalid =
7777
passwordOne !== passwordTwo ||
7878
passwordOne === '' ||
79-
username === '';
79+
username === '' ||
80+
email === '';
8081

8182
return (
8283
<form onSubmit={this.onSubmit}>
@@ -118,7 +119,7 @@ const SignUpLink = () =>
118119
<p>
119120
Don't have an account?
120121
{' '}
121-
<Link to="/signup">Sign Up</Link>
122+
<Link to={routes.SIGN_UP}>Sign Up</Link>
122123
</p>
123124

124125
export default withRouter(SignUpPage);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /