added redirect from login page to publish page if user logs in

This commit is contained in:
bill bittner 2018-02-02 14:24:46 -08:00
parent ba465fdfb7
commit 5f70cdd979
5 changed files with 28 additions and 10 deletions

View file

@ -1,4 +1,4 @@
import React from 'react/index';
import React from 'react';
import AssetPreview from 'components/AssetPreview';
import request from 'utils/request';

View file

@ -0,0 +1,10 @@
import {connect} from 'react-redux';
import View from './view';
const mapStateToProps = ({ channel }) => {
return {
loggedInChannelName: channel.loggedInChannel.name,
};
};
export default connect(mapStateToProps, null)(View);

View file

@ -1,9 +1,17 @@
import React from 'react';
import { withRouter } from 'react-router-dom';
import NavBar from 'containers/NavBar';
import ChannelLoginForm from 'containers/ChannelLoginForm';
import ChannelCreateForm from 'containers/ChannelCreateForm';
class PublishPage extends React.Component {
componentWillReceiveProps (newProps) {
// re-route the user to the homepage if the user is logged in
if (newProps.loggedInChannelName !== this.props.loggedInChannelName) {
console.log('user logged into new channel:', newProps.loggedInChannelName);
this.props.history.push(`/`);
}
}
render () {
return (
<div>
@ -27,4 +35,4 @@ class PublishPage extends React.Component {
}
};
export default PublishPage;
export default withRouter(PublishPage);

View file

@ -5,7 +5,7 @@ import { BrowserRouter, Route, Switch } from 'react-router-dom';
import PublishPage from 'components/PublishPage';
import AboutPage from 'components/AboutPage';
import LoginPage from 'components/LoginPage';
import LoginPage from 'containers/LoginPage';
import ShowPage from 'containers/ShowPage';
const Root = ({ store }) => (

View file

@ -1,6 +1,6 @@
// load dependencies
const logger = require('winston');
const db = require('../models/index'); // require our models for syncing
const db = require('../models'); // require our models for syncing
// configure logging
const config = require('../config/speechConfig.js');
const { logLevel } = config.logging;