Skip to content
Snippets Groups Projects
Commit 5fbddd4e authored by john's avatar john
Browse files

logout redirects you to /

parent 64022505
No related branches found
No related tags found
No related merge requests found
import React from 'react' import React from 'react'
import { browserHistory } from 'react-router'
import { LinkContainer } from 'react-router-bootstrap' import { LinkContainer } from 'react-router-bootstrap'
import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap' import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap'
...@@ -6,39 +7,61 @@ import Authorize from 'pubsweet-frontend/src/helpers/Authorize' ...@@ -6,39 +7,61 @@ import Authorize from 'pubsweet-frontend/src/helpers/Authorize'
import NavbarUser from 'pubsweet-component-navigation/NavbarUser' import NavbarUser from 'pubsweet-component-navigation/NavbarUser'
export default class Navigation extends React.Component { export default class Navigation extends React.Component {
constructor (props) {
super(props)
this.logout = this.logout.bind(this)
}
logout () {
const { logoutUser } = this.props.actions
logoutUser()
browserHistory.push('/')
}
render () { render () {
const { actions, currentUser } = this.props const { currentUser } = this.props
let logoutButtonIfAuthenticated let logoutButtonIfAuthenticated
if (currentUser.isAuthenticated) { if (currentUser.isAuthenticated) {
logoutButtonIfAuthenticated = <NavbarUser logoutButtonIfAuthenticated = (
user={currentUser.user} <NavbarUser
onLogoutClick={actions.logoutUser} user={currentUser.user}
/> onLogoutClick={this.logout}
/>
)
} }
// TODO -- fix object properties underneath
return ( return (
<Navbar fluid> <Navbar fluid>
<Navbar.Header> <Navbar.Header>
<NavbarBrand> <NavbarBrand>
<a href='#'><img src='/pubsweet.jpg' alt='pubsweet' /></a> <a href='#'><img src='/pubsweet.jpg' alt='pubsweet' /></a>
</NavbarBrand> </NavbarBrand>
</Navbar.Header> </Navbar.Header>
<Nav> <Nav>
<LinkContainer to='/books'> <LinkContainer to='/books'>
<NavItem>Books</NavItem> <NavItem>Books</NavItem>
</LinkContainer> </LinkContainer>
<Authorize operation='read' object={currentUser.user}> <Authorize operation='read' object={currentUser.user}>
<LinkContainer to='/users'> <LinkContainer to='/users'>
<NavItem>Users</NavItem> <NavItem>Users</NavItem>
</LinkContainer> </LinkContainer>
</Authorize> </Authorize>
<Authorize operation='read'> <Authorize operation='read'>
<LinkContainer to='/teams'> <LinkContainer to='/teams'>
<NavItem>Teams</NavItem> <NavItem>Teams</NavItem>
</LinkContainer> </LinkContainer>
</Authorize> </Authorize>
</Nav> </Nav>
{ logoutButtonIfAuthenticated } { logoutButtonIfAuthenticated }
</Navbar> </Navbar>
) )
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment