move logout functionality to logout page
This commit is contained in:
parent
f308d32739
commit
518fb7d9de
5 changed files with 29 additions and 21 deletions
|
|
@ -9,7 +9,7 @@ const Authenticated = ({ loggingIn, authenticated, component, path, exact, ...re
|
||||||
render={props => (
|
render={props => (
|
||||||
authenticated ?
|
authenticated ?
|
||||||
(React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) :
|
(React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) :
|
||||||
(<Redirect to="/logout" />)
|
(<Redirect to="/login" />)
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
import { LinkContainer } from 'react-router-bootstrap';
|
import { LinkContainer } from 'react-router-bootstrap';
|
||||||
import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
|
import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
|
|
||||||
const AuthenticatedNavigation = ({ name }) => (
|
const AuthenticatedNavigation = ({ name, history }) => (
|
||||||
<div>
|
<div>
|
||||||
<Nav>
|
<Nav>
|
||||||
<LinkContainer to="/documents">
|
<LinkContainer to="/documents">
|
||||||
|
|
@ -17,7 +18,7 @@ const AuthenticatedNavigation = ({ name }) => (
|
||||||
<NavItem eventKey={2.1} href="/profile">Profile</NavItem>
|
<NavItem eventKey={2.1} href="/profile">Profile</NavItem>
|
||||||
</LinkContainer>
|
</LinkContainer>
|
||||||
<MenuItem divider />
|
<MenuItem divider />
|
||||||
<MenuItem eventKey={2.2} onClick={() => Meteor.logout()}>Logout</MenuItem>
|
<MenuItem eventKey={2.2} onClick={() => history.push('/logout')}>Logout</MenuItem>
|
||||||
</NavDropdown>
|
</NavDropdown>
|
||||||
</Nav>
|
</Nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -27,4 +28,4 @@ AuthenticatedNavigation.propTypes = {
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AuthenticatedNavigation;
|
export default withRouter(AuthenticatedNavigation);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ const App = props => (
|
||||||
<Authenticated exact path="/profile" component={Profile} {...props} />
|
<Authenticated exact path="/profile" component={Profile} {...props} />
|
||||||
<Public path="/signup" component={Signup} {...props} />
|
<Public path="/signup" component={Signup} {...props} />
|
||||||
<Public path="/login" component={Login} {...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="verify-email" path="/verify-email/:token" component={VerifyEmail} />
|
||||||
<Route name="recover-password" path="/recover-password" component={RecoverPassword} />
|
<Route name="recover-password" path="/recover-password" component={RecoverPassword} />
|
||||||
<Route name="reset-password" path="/reset-password/:token" component={ResetPassword} />
|
<Route name="reset-password" path="/reset-password/:token" component={ResetPassword} />
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ class Login extends React.Component {
|
||||||
Bert.alert(error.reason, 'danger');
|
Bert.alert(error.reason, 'danger');
|
||||||
} else {
|
} else {
|
||||||
Bert.alert('Welcome back!', 'success');
|
Bert.alert('Welcome back!', 'success');
|
||||||
history.push('/documents');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,13 @@ import Icon from '../../components/Icon/Icon';
|
||||||
|
|
||||||
import './Logout.scss';
|
import './Logout.scss';
|
||||||
|
|
||||||
const Logout = () => (
|
class Logout extends React.Component {
|
||||||
|
componentDidMount() {
|
||||||
|
Meteor.logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
<div className="Logout">
|
<div className="Logout">
|
||||||
<img
|
<img
|
||||||
src="https://s3-us-west-2.amazonaws.com/cleverbeagle-assets/graphics/email-icon.png"
|
src="https://s3-us-west-2.amazonaws.com/cleverbeagle-assets/graphics/email-icon.png"
|
||||||
|
|
@ -17,7 +23,9 @@ const Logout = () => (
|
||||||
<li><a href="https://github.com/cleverbeagle"><Icon icon="github" /></a></li>
|
<li><a href="https://github.com/cleverbeagle"><Icon icon="github" /></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Logout.propTypes = {};
|
Logout.propTypes = {};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue