mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Generalize ProxyHandler to take arbitrary redirect functions
This commit is contained in:
parent
7cb5fa6758
commit
50377ba478
@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { History, RouteContext } from 'react-router';
|
import { RouteContext } from 'react-router';
|
||||||
|
import history from '../../history';
|
||||||
|
|
||||||
import UserStore from '../../stores/user_store';
|
import UserStore from '../../stores/user_store';
|
||||||
import UserActions from '../../actions/user_actions';
|
import UserActions from '../../actions/user_actions';
|
||||||
@ -12,18 +13,12 @@ import AppConstants from '../../constants/application_constants';
|
|||||||
const { object } = React.PropTypes;
|
const { object } = React.PropTypes;
|
||||||
const WHEN_ENUM = ['loggedIn', 'loggedOut'];
|
const WHEN_ENUM = ['loggedIn', 'loggedOut'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used in combination with `Route` as an intermediate Handler
|
* Redirects the user conditionally according to his authentication
|
||||||
* between the actual component we want to display dependent on a certain state
|
|
||||||
* that is required to display that component.
|
|
||||||
*
|
*
|
||||||
* @param {string} options.to Any type of route path that is defined in routes.js
|
|
||||||
* @param {enum/string} options.when ('loggedIn' || 'loggedOut')
|
* @param {enum/string} options.when ('loggedIn' || 'loggedOut')
|
||||||
*/
|
*/
|
||||||
export function ProxyHandler({to, when}) {
|
export function AuthRedirect({to, when}) {
|
||||||
|
|
||||||
// validate `when`, must be contained in `WHEN_ENUM`.
|
// validate `when`, must be contained in `WHEN_ENUM`.
|
||||||
// Throw an error otherwise.
|
// Throw an error otherwise.
|
||||||
if(WHEN_ENUM.indexOf(when) === -1) {
|
if(WHEN_ENUM.indexOf(when) === -1) {
|
||||||
@ -31,6 +26,52 @@ export function ProxyHandler({to, when}) {
|
|||||||
throw new Error(`"when" must be one of: [${whenValues}] got "${when}" instead`);
|
throw new Error(`"when" must be one of: [${whenValues}] got "${when}" instead`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return function(currentUser, query) {
|
||||||
|
const { redirectAuthenticated, redirect } = query;
|
||||||
|
|
||||||
|
// The user of this handler specifies with `when`, what kind of status
|
||||||
|
// needs to be checked to conditionally do - if that state is `true` -
|
||||||
|
// a redirect.
|
||||||
|
//
|
||||||
|
// So if when === 'loggedIn', we're checking if the user is logged in (and
|
||||||
|
// vice versa)
|
||||||
|
let exprToValidate = when === 'loggedIn' ? currentUser && currentUser.email
|
||||||
|
: currentUser && !currentUser.email;
|
||||||
|
|
||||||
|
// and redirect if `true`.
|
||||||
|
if(exprToValidate) {
|
||||||
|
window.setTimeout(() => history.replaceState(null, to, query));
|
||||||
|
|
||||||
|
// Otherwise there can also be the case that the backend
|
||||||
|
// wants to redirect the user to a specific route when the user is logged out already
|
||||||
|
} else if(!exprToValidate && when === 'loggedIn' && redirect) {
|
||||||
|
|
||||||
|
delete query.redirect;
|
||||||
|
window.setTimeout(() => history.replaceState(null, '/' + redirect, query));
|
||||||
|
|
||||||
|
} else if(!exprToValidate && when === 'loggedOut' && redirectAuthenticated) {
|
||||||
|
/*
|
||||||
|
* redirectAuthenticated contains an arbitrary path
|
||||||
|
* eg pieces/<id>, editions/<bitcoin_id>, collection, settings, ...
|
||||||
|
* hence transitionTo cannot be used directly.
|
||||||
|
*
|
||||||
|
* While we're getting rid of `query.redirect` explicitly in the
|
||||||
|
* above `else if` statement, here it's sufficient to just call
|
||||||
|
* `baseUrl` + `redirectAuthenticated`, as it gets rid of queries as well.
|
||||||
|
*/
|
||||||
|
window.location = AppConstants.baseUrl + redirectAuthenticated;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used in combination with `Route` as an intermediate Handler
|
||||||
|
* between the actual component we want to display dependent on a certain state
|
||||||
|
* that is required to display that component.
|
||||||
|
*
|
||||||
|
* @param {[function]} redirectFn A function that conditionally redirects
|
||||||
|
*/
|
||||||
|
export function ProxyHandler(redirectFn) {
|
||||||
return (Component) => {
|
return (Component) => {
|
||||||
return React.createClass({
|
return React.createClass({
|
||||||
displayName: 'ProxyHandler',
|
displayName: 'ProxyHandler',
|
||||||
@ -41,7 +82,7 @@ export function ProxyHandler({to, when}) {
|
|||||||
|
|
||||||
// We need insert `RouteContext` here in order to be able
|
// We need insert `RouteContext` here in order to be able
|
||||||
// to use the `Lifecycle` widget in further down nested components
|
// to use the `Lifecycle` widget in further down nested components
|
||||||
mixins: [History, RouteContext],
|
mixins: [RouteContext],
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return UserStore.getState();
|
return UserStore.getState();
|
||||||
@ -53,10 +94,10 @@ export function ProxyHandler({to, when}) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
// Only refresh this component, when UserSources are not loading
|
|
||||||
// data from the server
|
|
||||||
if(!UserStore.isLoading()) {
|
if(!UserStore.isLoading()) {
|
||||||
this.redirectConditionally();
|
const { currentUser } = this.state;
|
||||||
|
const { query } = this.props.location;
|
||||||
|
redirectFn(currentUser, query);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -64,45 +105,6 @@ export function ProxyHandler({to, when}) {
|
|||||||
UserStore.unlisten(this.onChange);
|
UserStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
redirectConditionally() {
|
|
||||||
const { query } = this.props.location;
|
|
||||||
const { redirectAuthenticated, redirect } = query;
|
|
||||||
|
|
||||||
// The user of this handler specifies with `when`, what kind of status
|
|
||||||
// needs to be checked to conditionally do - if that state is `true` -
|
|
||||||
// a redirect.
|
|
||||||
//
|
|
||||||
// So if when === 'loggedIn', we're checking if the user is logged in (and
|
|
||||||
// vice versa)
|
|
||||||
let exprToValidate = when === 'loggedIn' ?
|
|
||||||
this.state.currentUser && this.state.currentUser.email :
|
|
||||||
this.state.currentUser && !this.state.currentUser.email;
|
|
||||||
|
|
||||||
// and redirect if `true`.
|
|
||||||
if(exprToValidate) {
|
|
||||||
window.setTimeout(() => this.history.replaceState(null, to, query));
|
|
||||||
|
|
||||||
// Otherwise there can also be the case that the backend
|
|
||||||
// wants to redirect the user to a specific route when the user is logged out already
|
|
||||||
} else if(!exprToValidate && when === 'loggedIn' && redirect) {
|
|
||||||
|
|
||||||
delete query.redirect;
|
|
||||||
window.setTimeout(() => this.history.replaceState(null, '/' + redirect, query));
|
|
||||||
|
|
||||||
} else if(!exprToValidate && when === 'loggedOut' && redirectAuthenticated) {
|
|
||||||
/*
|
|
||||||
* redirectAuthenticated contains an arbitrary path
|
|
||||||
* eg pieces/<id>, editions/<bitcoin_id>, collection, settings, ...
|
|
||||||
* hence transitionTo cannot be used directly.
|
|
||||||
*
|
|
||||||
* While we're getting rid of `query.redirect` explicitly in the
|
|
||||||
* above `else if` statement, here it's sufficient to just call
|
|
||||||
* `baseUrl` + `redirectAuthenticated`, as it gets rid of queries as well.
|
|
||||||
*/
|
|
||||||
window.location = AppConstants.baseUrl + redirectAuthenticated;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
@ -22,7 +22,7 @@ import PasswordResetContainer from '../../password_reset_container';
|
|||||||
import CoaVerifyContainer from '../../coa_verify_container';
|
import CoaVerifyContainer from '../../coa_verify_container';
|
||||||
import ErrorNotFoundPage from '../../error_not_found_page';
|
import ErrorNotFoundPage from '../../error_not_found_page';
|
||||||
|
|
||||||
import { ProxyHandler } from '../../../components/ascribe_routes/proxy_handler';
|
import { ProxyHandler, AuthRedirect } from '../../../components/ascribe_routes/proxy_handler';
|
||||||
|
|
||||||
|
|
||||||
const ROUTES = {
|
const ROUTES = {
|
||||||
@ -31,26 +31,26 @@ const ROUTES = {
|
|||||||
<IndexRoute component={SPLanding} />
|
<IndexRoute component={SPLanding} />
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SPLoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPLoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SPSignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SPSignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPSettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPSettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'/>
|
headerTitle='+ NEW WORK'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SPPieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SPPieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
|
|
||||||
<Route path='pieces/:pieceId' component={SPPieceContainer} />
|
<Route path='pieces/:pieceId' component={SPPieceContainer} />
|
||||||
@ -64,20 +64,20 @@ const ROUTES = {
|
|||||||
<IndexRoute component={PRLanding} />
|
<IndexRoute component={PRLanding} />
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(PRRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PRRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'/>
|
headerTitle='+ NEW WORK'/>
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPLoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/register_piece', when: 'loggedIn'}))(SPLoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(SPSignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/register_piece', when: 'loggedIn'}))(SPSignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/register_piece', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/register_piece', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route path='pieces/:pieceId' component={SPPieceContainer} />
|
<Route path='pieces/:pieceId' component={SPPieceContainer} />
|
||||||
<Route path='*' component={ErrorNotFoundPage} />
|
<Route path='*' component={ErrorNotFoundPage} />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -40,7 +40,7 @@ import LumenusLanding from './components/lumenus/lumenus_landing';
|
|||||||
import Vivi23Landing from './components/23vivi/23vivi_landing';
|
import Vivi23Landing from './components/23vivi/23vivi_landing';
|
||||||
import Vivi23PieceList from './components/23vivi/23vivi_piece_list';
|
import Vivi23PieceList from './components/23vivi/23vivi_piece_list';
|
||||||
|
|
||||||
import { ProxyHandler } from '../../../components/ascribe_routes/proxy_handler';
|
import { ProxyHandler, AuthRedirect } from '../../../components/ascribe_routes/proxy_handler';
|
||||||
|
|
||||||
import WalletApp from './wallet_app';
|
import WalletApp from './wallet_app';
|
||||||
|
|
||||||
@ -51,29 +51,29 @@ let ROUTES = {
|
|||||||
<IndexRoute component={CylandLanding} />
|
<IndexRoute component={CylandLanding} />
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_settings'
|
path='contract_settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)}/>
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(CylandRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(CylandRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'/>
|
headerTitle='+ NEW WORK'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(CylandPieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(CylandPieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
<Route path='editions/:editionId' component={EditionContainer} />
|
<Route path='editions/:editionId' component={EditionContainer} />
|
||||||
<Route path='verify' component={CoaVerifyContainer} />
|
<Route path='verify' component={CoaVerifyContainer} />
|
||||||
@ -85,29 +85,29 @@ let ROUTES = {
|
|||||||
<Route path='/' component={WalletApp}>
|
<Route path='/' component={WalletApp}>
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_settings'
|
path='contract_settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)}/>
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(CCRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(CCRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'/>
|
headerTitle='+ NEW WORK'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
<Route path='pieces/:pieceId' component={PieceContainer} />
|
<Route path='pieces/:pieceId' component={PieceContainer} />
|
||||||
<Route path='editions/:editionId' component={EditionContainer} />
|
<Route path='editions/:editionId' component={EditionContainer} />
|
||||||
@ -120,39 +120,39 @@ let ROUTES = {
|
|||||||
<IndexRoute component={IkonotvLanding} />
|
<IndexRoute component={IkonotvLanding} />
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_settings'
|
path='contract_settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)}/>
|
||||||
<Route
|
<Route
|
||||||
path='request_loan'
|
path='request_loan'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SendContractAgreementForm)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SendContractAgreementForm)}
|
||||||
headerTitle='SEND NEW CONTRACT'
|
headerTitle='SEND NEW CONTRACT'
|
||||||
aclName='acl_create_contractagreement'/>
|
aclName='acl_create_contractagreement'/>
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(IkonotvRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'
|
headerTitle='+ NEW WORK'
|
||||||
aclName='acl_create_piece'/>
|
aclName='acl_create_piece'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvPieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(IkonotvPieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_notifications'
|
path='contract_notifications'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(IkonotvContractNotifications)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(IkonotvContractNotifications)}/>
|
||||||
<Route path='pieces/:pieceId' component={IkonotvPieceContainer} />
|
<Route path='pieces/:pieceId' component={IkonotvPieceContainer} />
|
||||||
<Route path='editions/:editionId' component={EditionContainer} />
|
<Route path='editions/:editionId' component={EditionContainer} />
|
||||||
<Route path='verify' component={CoaVerifyContainer} />
|
<Route path='verify' component={CoaVerifyContainer} />
|
||||||
@ -161,32 +161,32 @@ let ROUTES = {
|
|||||||
),
|
),
|
||||||
'lumenus': (
|
'lumenus': (
|
||||||
<Route path='/' component={WalletApp}>
|
<Route path='/' component={WalletApp}>
|
||||||
<IndexRoute component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LumenusLanding)} />
|
<IndexRoute component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LumenusLanding)} />
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_settings'
|
path='contract_settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)}/>
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(MarketRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'/>
|
headerTitle='+ NEW WORK'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketPieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(MarketPieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
<Route path='pieces/:pieceId' component={MarketPieceContainer} />
|
<Route path='pieces/:pieceId' component={MarketPieceContainer} />
|
||||||
<Route path='editions/:editionId' component={MarketEditionContainer} />
|
<Route path='editions/:editionId' component={MarketEditionContainer} />
|
||||||
@ -196,33 +196,33 @@ let ROUTES = {
|
|||||||
),
|
),
|
||||||
'23vivi': (
|
'23vivi': (
|
||||||
<Route path='/' component={WalletApp}>
|
<Route path='/' component={WalletApp}>
|
||||||
<IndexRoute component={ProxyHandler({to: '/collection', when: 'loggedIn'})(Vivi23Landing)} />
|
<IndexRoute component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(Vivi23Landing)} />
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/', when: 'loggedOut'}))(LogoutContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_settings'
|
path='contract_settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)}/>
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(MarketRegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(MarketRegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'
|
headerTitle='+ NEW WORK'
|
||||||
aclName='acl_wallet_submit'/>
|
aclName='acl_wallet_submit'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(Vivi23PieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(Vivi23PieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
<Route path='pieces/:pieceId' component={MarketPieceContainer} />
|
<Route path='pieces/:pieceId' component={MarketPieceContainer} />
|
||||||
<Route path='editions/:editionId' component={MarketEditionContainer} />
|
<Route path='editions/:editionId' component={MarketEditionContainer} />
|
||||||
|
18
js/routes.js
18
js/routes.js
@ -25,39 +25,39 @@ import ErrorNotFoundPage from './components/error_not_found_page';
|
|||||||
|
|
||||||
import RegisterPiece from './components/register_piece';
|
import RegisterPiece from './components/register_piece';
|
||||||
|
|
||||||
import { ProxyHandler } from './components/ascribe_routes/proxy_handler';
|
import { ProxyHandler, AuthRedirect } from './components/ascribe_routes/proxy_handler';
|
||||||
|
|
||||||
|
|
||||||
let COMMON_ROUTES = (
|
let COMMON_ROUTES = (
|
||||||
<Route path='/' component={App}>
|
<Route path='/' component={App}>
|
||||||
<Route
|
<Route
|
||||||
path='login'
|
path='login'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(LoginContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(LoginContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='register_piece'
|
path='register_piece'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(RegisterPiece)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(RegisterPiece)}
|
||||||
headerTitle='+ NEW WORK'/>
|
headerTitle='+ NEW WORK'/>
|
||||||
<Route
|
<Route
|
||||||
path='collection'
|
path='collection'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(PieceList)}
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(PieceList)}
|
||||||
headerTitle='COLLECTION'/>
|
headerTitle='COLLECTION'/>
|
||||||
<Route
|
<Route
|
||||||
path='signup'
|
path='signup'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(SignupContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(SignupContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='logout'
|
path='logout'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(LogoutContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(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
|
<Route
|
||||||
path='password_reset'
|
path='password_reset'
|
||||||
component={ProxyHandler({to: '/collection', when: 'loggedIn'})(PasswordResetContainer)} />
|
component={ProxyHandler(AuthRedirect({to: '/collection', when: 'loggedIn'}))(PasswordResetContainer)} />
|
||||||
<Route
|
<Route
|
||||||
path='settings'
|
path='settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(SettingsContainer)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(SettingsContainer)}/>
|
||||||
<Route
|
<Route
|
||||||
path='contract_settings'
|
path='contract_settings'
|
||||||
component={ProxyHandler({to: '/login', when: 'loggedOut'})(ContractSettings)}/>
|
component={ProxyHandler(AuthRedirect({to: '/login', when: 'loggedOut'}))(ContractSettings)}/>
|
||||||
<Route path='coa_verify' component={CoaVerifyContainer} />
|
<Route path='coa_verify' component={CoaVerifyContainer} />
|
||||||
<Route path='*' component={ErrorNotFoundPage} />
|
<Route path='*' component={ErrorNotFoundPage} />
|
||||||
</Route>
|
</Route>
|
||||||
|
Loading…
Reference in New Issue
Block a user