Fix up redux connection for auth
This commit is contained in:
parent
5a057337cd
commit
bc6dadb350
2 changed files with 5 additions and 5 deletions
|
@ -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 (
|
||||
<div>
|
||||
<div className="ui four item secondary menu">
|
||||
|
@ -28,7 +29,7 @@ class NavBar extends Component {
|
|||
<NavLink to="/posts/" className='item' activeClassName='active'>Posts</NavLink>
|
||||
<NavLink to="/about/" className='item' activeClassName='active'>About</NavLink>
|
||||
<div onClick={this.handleLoginDropdown} className='item ui button dropdown'>
|
||||
{this.state.user_or_login}
|
||||
{user.user_authed ? user.username : 'Login'}
|
||||
<i className="dropdown icon"></i>
|
||||
<AuthMenu auth_menu_visible={this.state.auth_menu_visible} close={ () => this.setState({auth_menu_visible: false})}></AuthMenu>
|
||||
</div>
|
||||
|
@ -40,8 +41,7 @@ class NavBar extends Component {
|
|||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
user_authed: state.user_authed,
|
||||
username: state.username
|
||||
user: state.auth,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}}
|
||||
}
|
||||
|
|
Reference in a new issue