diff --git a/src/components/NavBar.js b/src/components/NavBar.js index ffbcc7d..9819c5c 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -7,7 +7,7 @@ class NavBar extends Component { constructor (props) { super(props) this.state = { - logged_in: false, + user_authed: false, auth_menu_visible: false, user_or_login: 'Login' } @@ -21,6 +21,7 @@ class NavBar extends Component { } render() { + const { user } = this.props; return (
@@ -28,7 +29,7 @@ class NavBar extends Component { Posts About
- {this.state.user_or_login} + {user.user_authed ? user.username : 'Login'} this.setState({auth_menu_visible: false})}>
@@ -40,8 +41,7 @@ class NavBar extends Component { const mapStateToProps = (state) => { return { - user_authed: state.user_authed, - username: state.username + user: state.auth, }; } diff --git a/src/reducers/authReducer.js b/src/reducers/authReducer.js index 3b4fdc5..a68f4bd 100644 --- a/src/reducers/authReducer.js +++ b/src/reducers/authReducer.js @@ -13,7 +13,7 @@ export default (state = initialState, action) => { if (action.payload) { var data = JSON.parse(atob(action.payload.data.split('.')[1])) return {...state, ...{ - user_logged_in: true, + user_authed: true, username: data.username, }} }