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>
@ -14,17 +22,17 @@ class PublishPage extends React.Component {
<p>Channels allow you to publish and group content under an identity. You can create a channel for yourself, or share one with like-minded friends. You can create 1 channel, or 100, so whether you're <a className="link--primary" target="_blank" href="/@catalonia2017:43dcf47163caa21d8404d9fe9b30f78ef3e146a8">documenting important events</a>, or making a public repository for <a className="link--primary" target="_blank" href="/@catGifs">cat gifs</a> (password: '1234'), try creating a channel for it!</p>
</div>
</div><div className="column column--5 column--med-10 align-content-top">
<div className="column column--8 column--med-10">
<h3 className="h3--no-bottom">Log in to an existing channel:</h3>
<ChannelLoginForm />
<h3 className="h3--no-bottom">Create a brand new channel:</h3>
<ChannelCreateForm />
</div>
<div className="column column--8 column--med-10">
<h3 className="h3--no-bottom">Log in to an existing channel:</h3>
<ChannelLoginForm />
<h3 className="h3--no-bottom">Create a brand new channel:</h3>
<ChannelCreateForm />
</div>
</div>
</div>
</div>
);
}
};
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;