1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

login/logout functional

This commit is contained in:
ddejongh 2015-06-15 12:36:27 +02:00
parent 07686f514f
commit 66f8a6a1ca
3 changed files with 29 additions and 15 deletions

View File

@ -6,10 +6,13 @@ import Router from 'react-router';
import UserActions from '../actions/user_actions';
import UserStore from '../stores/user_store';
import apiUrls from '../constants/api_urls.js';
import PieceListActions from '../actions/piece_list_actions';
import Nav from 'react-bootstrap/lib/Nav';
import Navbar from 'react-bootstrap/lib/Navbar';
import NavItem from 'react-bootstrap/lib/NavItem';
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem';
@ -44,6 +47,26 @@ let Header = React.createClass({
},
render() {
let account = (
<ModalWrapper
button={<NavItem to="pieces">LOGIN</NavItem>}
title='Log in to ascribe'
handleSuccess={this.handleLoginSuccess}
tooltip='Log in to ascribe'>
<LoginForm />
</ModalWrapper>);
if (this.state.currentUser.username){
account = (
<DropdownButton eventKey="1" title={this.state.currentUser.username}>
<MenuItem eventKey="1" href="/art/account_settings/">{getLangText('Account Settings')}</MenuItem>
<li className="divider"></li>
<MenuItem eventKey="2" href="/art/faq/">{getLangText('FAQ')}</MenuItem>
<MenuItem eventKey="3" href="/art/terms/">{getLangText('Terms of Service')}</MenuItem>
<MenuItem divider />
<MenuItem eventKey="4" href={apiUrls.users_logout}>{getLangText('Log out')}</MenuItem>
</DropdownButton>
);
}
return (
<Navbar>
<Nav>
@ -53,21 +76,7 @@ let Header = React.createClass({
</Link>
</Nav>
<Nav right>
<ModalWrapper
button={<Link className='btn btn-default btn-sm' to="pieces">LOGIN</Link>}
title='Log in to ascribe'
handleSuccess={this.handleLoginSuccess}
tooltip='Log in to ascribe'>
<LoginForm />
</ModalWrapper>
<DropdownButton eventKey="1" title={this.state.currentUser.username}>
<MenuItem eventKey="1" href="/art/account_settings/">{getLangText('Account Settings')}</MenuItem>
<li className="divider"></li>
<MenuItem eventKey="2" href="/art/faq/">{getLangText('FAQ')}</MenuItem>
<MenuItem eventKey="3" href="/art/terms/">{getLangText('Terms of Service')}</MenuItem>
<MenuItem divider />
<MenuItem eventKey="4" href="/api/users/logout/">{getLangText('Log out')}</MenuItem>
</DropdownButton>
{account}
</Nav>
</Navbar>
);

View File

@ -24,6 +24,7 @@ let apiUrls = {
'note_notes': AppConstants.apiEndpoint + 'note/notes/',
'user': AppConstants.apiEndpoint + 'users/',
'users_login': AppConstants.apiEndpoint + 'users/login/',
'users_logout': AppConstants.apiEndpoint + 'users/logout/',
'users_signup': AppConstants.apiEndpoint + 'users/',
'users_password_reset_request': AppConstants.apiEndpoint + 'users/request_reset_password/',
'users_password_reset': AppConstants.apiEndpoint + 'users/reset_password/'

View File

@ -29,6 +29,10 @@ $BASE_URL: '<%= BASE_URL %>';
border-top:0;
}
.navbar-right {
margin-right: 0;
}
.clear-paddings {
padding-left:0;
padding-right:0;