move logout functionality to logout page

This commit is contained in:
cleverbeagle 2017-09-07 10:11:58 -05:00
parent f308d32739
commit 518fb7d9de
5 changed files with 29 additions and 21 deletions

View file

@ -9,7 +9,7 @@ const Authenticated = ({ loggingIn, authenticated, component, path, exact, ...re
render={props => (
authenticated ?
(React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) :
(<Redirect to="/logout" />)
(<Redirect to="/login" />)
)}
/>
);

View file

@ -1,10 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { LinkContainer } from 'react-router-bootstrap';
import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
import { Meteor } from 'meteor/meteor';
const AuthenticatedNavigation = ({ name }) => (
const AuthenticatedNavigation = ({ name, history }) => (
<div>
<Nav>
<LinkContainer to="/documents">
@ -17,7 +18,7 @@ const AuthenticatedNavigation = ({ name }) => (
<NavItem eventKey={2.1} href="/profile">Profile</NavItem>
</LinkContainer>
<MenuItem divider />
<MenuItem eventKey={2.2} onClick={() => Meteor.logout()}>Logout</MenuItem>
<MenuItem eventKey={2.2} onClick={() => history.push('/logout')}>Logout</MenuItem>
</NavDropdown>
</Nav>
</div>
@ -27,4 +28,4 @@ AuthenticatedNavigation.propTypes = {
name: PropTypes.string.isRequired,
};
export default AuthenticatedNavigation;
export default withRouter(AuthenticatedNavigation);

View file

@ -56,7 +56,7 @@ const App = props => (
<Authenticated exact path="/profile" component={Profile} {...props} />
<Public path="/signup" component={Signup} {...props} />
<Public path="/login" component={Login} {...props} />
<Public path="/logout" component={Logout} {...props} />
<Route path="/logout" component={Logout} {...props} />
<Route name="verify-email" path="/verify-email/:token" component={VerifyEmail} />
<Route name="recover-password" path="/recover-password" component={RecoverPassword} />
<Route name="reset-password" path="/reset-password/:token" component={ResetPassword} />

View file

@ -48,7 +48,6 @@ class Login extends React.Component {
Bert.alert(error.reason, 'danger');
} else {
Bert.alert('Welcome back!', 'success');
history.push('/documents');
}
});
}

View file

@ -3,21 +3,29 @@ import Icon from '../../components/Icon/Icon';
import './Logout.scss';
const Logout = () => (
<div className="Logout">
<img
src="https://s3-us-west-2.amazonaws.com/cleverbeagle-assets/graphics/email-icon.png"
alt="Clever Beagle"
/>
<h1>Stay safe out there.</h1>
<p>{'Don\'t forget to like and follow Clever Beagle elsewhere on the web:'}</p>
<ul className="FollowUsElsewhere">
<li><a href="https://facebook.com/cleverbeagle"><Icon icon="facebook-official" /></a></li>
<li><a href="https://twitter.com/clvrbgl"><Icon icon="twitter" /></a></li>
<li><a href="https://github.com/cleverbeagle"><Icon icon="github" /></a></li>
</ul>
</div>
);
class Logout extends React.Component {
componentDidMount() {
Meteor.logout();
}
render() {
return (
<div className="Logout">
<img
src="https://s3-us-west-2.amazonaws.com/cleverbeagle-assets/graphics/email-icon.png"
alt="Clever Beagle"
/>
<h1>Stay safe out there.</h1>
<p>{'Don\'t forget to like and follow Clever Beagle elsewhere on the web:'}</p>
<ul className="FollowUsElsewhere">
<li><a href="https://facebook.com/cleverbeagle"><Icon icon="facebook-official" /></a></li>
<li><a href="https://twitter.com/clvrbgl"><Icon icon="twitter" /></a></li>
<li><a href="https://github.com/cleverbeagle"><Icon icon="github" /></a></li>
</ul>
</div>
);
}
}
Logout.propTypes = {};