mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: logout should only be called once
This commit is contained in:
parent
217170c2e2
commit
367b5c8d85
@ -332,7 +332,7 @@ export const routes = [
|
||||
title: 'Sign out',
|
||||
icon: 'exit_to_app',
|
||||
component: LogoutFeatures,
|
||||
type: 'protected',
|
||||
type: 'unprotected',
|
||||
layout: 'main',
|
||||
},
|
||||
{
|
||||
|
@ -3,23 +3,27 @@ import PropTypes from 'prop-types';
|
||||
import { Card, CardContent, CardHeader } from '@material-ui/core';
|
||||
import { styles as commonStyles } from '../common';
|
||||
|
||||
const LogoutComponent = ({ logoutUser, history }) => {
|
||||
const LogoutComponent = ({ logoutUser, user }) => {
|
||||
useEffect(() => {
|
||||
logoutUser();
|
||||
});
|
||||
if(user) {
|
||||
logoutUser();
|
||||
}
|
||||
}, [user, logoutUser]);
|
||||
|
||||
return (
|
||||
<Card shadow={0} className={commonStyles.fullwidth}>
|
||||
<CardHeader>Logged out</CardHeader>
|
||||
<CardContent>
|
||||
You have now been successfully logged out of Unleash. Thank you
|
||||
for using Unleash.{' '}
|
||||
You have now been successfully logged out of Unleash.
|
||||
<br /> <br />
|
||||
Thank you for using Unleash.{' '}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
LogoutComponent.propTypes = {
|
||||
logoutUser: PropTypes.func.isRequired,
|
||||
user: PropTypes.object,
|
||||
};
|
||||
|
||||
export default LogoutComponent;
|
||||
|
@ -6,6 +6,8 @@ const mapDispatchToProps = {
|
||||
logoutUser,
|
||||
};
|
||||
|
||||
const mapStateToProps = () => ({});
|
||||
const mapStateToProps = (state) => ({
|
||||
user: state.user.get('profile'),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(LogoutComponent);
|
||||
|
@ -62,6 +62,7 @@ const features = (state = new List([]), action) => {
|
||||
return new List(action.featureToggles.map($Map));
|
||||
case USER_LOGIN:
|
||||
case USER_LOGOUT:
|
||||
console.log('clear toggle store');
|
||||
debug(USER_LOGOUT, action);
|
||||
return new List([]);
|
||||
default:
|
||||
|
@ -17,7 +17,7 @@ const userStore = (state = new $Map({permissions: []}), action) => {
|
||||
.set('showDialog', true);
|
||||
return state;
|
||||
case USER_LOGOUT:
|
||||
return new $Map();
|
||||
return new $Map({permissions: []});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user