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

Implement loggedOut routings

This commit is contained in:
Tim Daubenschütz 2015-10-07 09:39:30 +02:00
parent 471d95977e
commit b4f9c11c16
4 changed files with 41 additions and 31 deletions

View File

@ -6,27 +6,19 @@ import { History } from 'react-router';
import UserActions from '../actions/user_actions'; import UserActions from '../actions/user_actions';
import { alt, altWhitelabel, altUser, altThirdParty } from '../alt'; import { alt, altWhitelabel, altUser, altThirdParty } from '../alt';
import AppConstants from '../constants/application_constants';
let baseUrl = AppConstants.baseUrl;
let LogoutContainer = React.createClass({ let LogoutContainer = React.createClass({
mixins: [History], mixins: [History],
componentDidMount() { componentDidMount() {
UserActions.logoutCurrentUser() UserActions.logoutCurrentUser();
.then(() => { alt.flush();
alt.flush(); altWhitelabel.flush();
altWhitelabel.flush(); altUser.flush();
altUser.flush(); altThirdParty.flush();
altThirdParty.flush(); // kill intercom (with fire)
// kill intercom (with fire) window.Intercom('shutdown');
window.Intercom('shutdown');
this.history.replaceState(null, baseUrl);
})
.catch((err) => {
console.logGlobal(err);
});
}, },
render() { render() {

View File

@ -13,6 +13,10 @@ import { getLangText } from '../utils/lang_utils';
let PasswordResetContainer = React.createClass({ let PasswordResetContainer = React.createClass({
propTypes: {
location: React.PropTypes.object
},
getInitialState() { getInitialState() {
return {isRequested: false}; return {isRequested: false};
}, },
@ -22,12 +26,14 @@ let PasswordResetContainer = React.createClass({
}, },
render() { render() {
if (this.props.query.email && this.props.query.token) { let { location } = this.props;
if (location.query.email && location.query.token) {
return ( return (
<div> <div>
<PasswordResetForm <PasswordResetForm
email={this.props.query.email} email={location.query.email}
token={this.props.query.token}/> token={location.query.token}/>
</div> </div>
); );
} }

View File

@ -3,9 +3,6 @@
import React from 'react'; import React from 'react';
import { History } from 'react-router'; import { History } from 'react-router';
import Col from 'react-bootstrap/lib/Col';
import Row from 'react-bootstrap/lib/Row';
import WhitelabelActions from '../actions/whitelabel_actions'; import WhitelabelActions from '../actions/whitelabel_actions';
import WhitelabelStore from '../stores/whitelabel_store'; import WhitelabelStore from '../stores/whitelabel_store';
@ -20,10 +17,6 @@ import GlobalNotificationActions from '../actions/global_notification_actions';
import PropertyCollapsible from './ascribe_forms/property_collapsible'; import PropertyCollapsible from './ascribe_forms/property_collapsible';
import RegisterPieceForm from './ascribe_forms/form_register_piece'; import RegisterPieceForm from './ascribe_forms/form_register_piece';
import LoginContainer from './login_container';
import SlidesContainer from './ascribe_slides_container/slides_container';
import { mergeOptions } from '../utils/general_utils'; import { mergeOptions } from '../utils/general_utils';
import { getLangText } from '../utils/lang_utils'; import { getLangText } from '../utils/lang_utils';

View File

@ -44,14 +44,33 @@ let COMMON_ROUTES = (
path="login" path="login"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})} proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={LoginContainer} /> component={LoginContainer} />
<Route path="register_piece" component={RegisterPiece} headerTitle="+ NEW WORK" /> <ProxyRoute
<Route path="signup" component={SignupContainer} /> path="register_piece"
<Route path="logout" component={LogoutContainer} /> proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={RegisterPiece}
headerTitle="+ NEW WORK"/>
<ProxyRoute
path="signup"
proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={SignupContainer} />
<ProxyRoute
path="logout"
proxyHandler={RedirectProxyHandler({to: '/', when: 'loggedOut'})}
component={LogoutContainer}/>
<Route path="pieces/:pieceId" component={PieceContainer} /> <Route path="pieces/:pieceId" component={PieceContainer} />
<Route path="editions/:editionId" component={EditionContainer} /> <Route path="editions/:editionId" component={EditionContainer} />
<Route path="password_reset" component={PasswordResetContainer} /> <ProxyRoute
<Route path="settings" component={SettingsContainer} /> path="password_reset"
<Route path="contract_settings" component={ContractSettings} /> proxyHandler={RedirectProxyHandler({to: '/collection', when: 'loggedIn'})}
component={PasswordResetContainer} />
<ProxyRoute
path="settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={SettingsContainer}/>
<ProxyRoute
path="contract_settings"
proxyHandler={RedirectProxyHandler({to: '/login', when: 'loggedOut'})}
component={ContractSettings}/>
<Route path="coa_verify" component={CoaVerifyContainer} /> <Route path="coa_verify" component={CoaVerifyContainer} />
<Route path="*" component={ErrorNotFoundPage} /> <Route path="*" component={ErrorNotFoundPage} />
</Route> </Route>