1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Logout is now a route

This commit is contained in:
vrde 2015-07-17 15:02:44 +02:00
parent 18a37057e5
commit b536af29be
4 changed files with 35 additions and 1 deletions

View File

@ -119,7 +119,7 @@ let Header = React.createClass({
<DropdownButton eventKey="1" title={this.state.currentUser.username}> <DropdownButton eventKey="1" title={this.state.currentUser.username}>
<MenuItemLink eventKey="2" to="settings">{getLangText('Account Settings')}</MenuItemLink> <MenuItemLink eventKey="2" to="settings">{getLangText('Account Settings')}</MenuItemLink>
<MenuItem divider /> <MenuItem divider />
<MenuItem eventKey="3" onClick={this.handleLogout}>{getLangText('Log out')}</MenuItem> <MenuItemLink eventKey="3" to="logout">{getLangText('Log out')}</MenuItemLink>
</DropdownButton> </DropdownButton>
); );

View File

@ -0,0 +1,30 @@
'use strict';
import React from 'react';
import Router from 'react-router';
let Link = Router.Link;
import UserActions from '../actions/user_actions';
import Alt from '../alt';
let LogoutContainer = React.createClass({
mixins: [Router.Navigation, Router.State],
componentDidMount() {
UserActions.logoutCurrentUser();
Alt.flush();
// kill intercom (with fire)
window.Intercom('shutdown');
this.transitionTo('/');
},
render() {
return null;
}
});
export default LogoutContainer;

View File

@ -5,6 +5,7 @@ import Router from 'react-router';
import Landing from './components/landing'; import Landing from './components/landing';
import LoginContainer from './components/login_container'; import LoginContainer from './components/login_container';
import LogoutContainer from '../../../components/logout_container';
import SignupContainer from './components/signup_container'; import SignupContainer from './components/signup_container';
import PasswordResetContainer from '../../../components/password_reset_container'; import PasswordResetContainer from '../../../components/password_reset_container';
import PrizeRegisterPiece from './components/register_piece'; import PrizeRegisterPiece from './components/register_piece';
@ -25,6 +26,7 @@ function getRoutes(commonRoutes) {
<Route name="app" path={baseUrl} handler={App}> <Route name="app" path={baseUrl} handler={App}>
<Route name="landing" path={baseUrl} handler={Landing} /> <Route name="landing" path={baseUrl} handler={Landing} />
<Route name="login" path="login" handler={LoginContainer} /> <Route name="login" path="login" handler={LoginContainer} />
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="signup" path="signup" handler={SignupContainer} /> <Route name="signup" path="signup" handler={SignupContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} /> <Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="register_piece" path="register_piece" handler={PrizeRegisterPiece} /> <Route name="register_piece" path="register_piece" handler={PrizeRegisterPiece} />

View File

@ -11,6 +11,7 @@ import PieceContainer from './components/ascribe_detail/piece_container';
import EditionContainer from './components/ascribe_detail/edition_container'; import EditionContainer from './components/ascribe_detail/edition_container';
import LoginContainer from './components/login_container'; import LoginContainer from './components/login_container';
import LogoutContainer from './components/logout_container';
import SignupContainer from './components/signup_container'; import SignupContainer from './components/signup_container';
import PasswordResetContainer from './components/password_reset_container'; import PasswordResetContainer from './components/password_reset_container';
@ -26,6 +27,7 @@ const COMMON_ROUTES = (
<Route> <Route>
<Route name="signup" path="signup" handler={SignupContainer} /> <Route name="signup" path="signup" handler={SignupContainer} />
<Route name="login" path="login" handler={LoginContainer} /> <Route name="login" path="login" handler={LoginContainer} />
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="pieces" path="collection" handler={PieceList} /> <Route name="pieces" path="collection" handler={PieceList} />
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} /> <Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} /> <Route name="edition" path="editions/:editionId" handler={EditionContainer} />