File tree 3 files changed +8
-4
lines changed
3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,6 @@ AccountPage.contextTypes = {
16
16
authUser : PropTypes . object ,
17
17
} ;
18
18
19
- export default withAuthorization ( true ) ( AccountPage ) ;
19
+ const authCondition = ( authUser ) => ! ! authUser ;
20
+
21
+ export default withAuthorization ( authCondition ) ( AccountPage ) ;
Original file line number Diff line number Diff line change @@ -45,4 +45,6 @@ const UserList = ({ users }) =>
45
45
) }
46
46
</ div >
47
47
48
- export default withAuthorization ( true ) ( HomePage ) ;
48
+ const authCondition = ( authUser ) => ! ! authUser ;
49
+
50
+ export default withAuthorization ( authCondition ) ( HomePage ) ;
Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ import { withRouter } from 'react-router-dom';
5
5
import { firebase } from '../../firebase' ;
6
6
import * as routes from '../../constants/routes' ;
7
7
8
- const withAuthorization = ( needsAuthorization ) => ( Component ) => {
8
+ const withAuthorization = ( condition ) => ( Component ) => {
9
9
class WithAuthorization extends React . Component {
10
10
componentDidMount ( ) {
11
11
firebase . auth . onAuthStateChanged ( authUser => {
12
- if ( ! authUser && needsAuthorization ) {
12
+ if ( ! condition ( authUser ) ) {
13
13
this . props . history . push ( routes . SIGN_IN ) ;
14
14
}
15
15
} ) ;
You can’t perform that action at this time.
0 commit comments