Fix: Clear stores when user logs out (#65)
* Import missing action types for logout * Correctly destructure logout response from doFetchWithResponse * Return to SelectServer upon logout * Add todo regarding clearing clientConfig upon logout
This commit is contained in:
parent
f2800ce927
commit
23a8676c19
7 changed files with 12 additions and 6 deletions
|
|
@ -183,7 +183,7 @@ export default class Client {
|
|||
}
|
||||
|
||||
logout = async () => {
|
||||
const response = await this.doFetchWithResponse(
|
||||
const {response} = await this.doFetchWithResponse(
|
||||
`${this.getUsersRoute()}/logout`,
|
||||
{method: 'post'}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Logout extends Component {
|
|||
componentWillReceiveProps(newProps) {
|
||||
if (this.props.logout.status === 'fetching' &&
|
||||
newProps.logout.status === 'fetched') {
|
||||
Routes.popTo('goToLogin');
|
||||
Routes.popTo('goToSelectServer');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
import {ChannelsTypes as types} from 'constants';
|
||||
import {ChannelsTypes, LogoutTypes} from 'constants';
|
||||
const types = {...ChannelsTypes, ...LogoutTypes};
|
||||
|
||||
export const initState = {
|
||||
status: 'not fetched',
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import {GeneralTypes as types} from 'constants';
|
|||
|
||||
export const initState = initialState();
|
||||
|
||||
// TODO: clientConfig should be cleared when the user logs out.
|
||||
// We can't do so until it's extracted into its own store with more reducers
|
||||
export function clientConfig(state = initState, action) {
|
||||
return handle(
|
||||
types.CLIENT_CONFIG_REQUEST,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {LoginTypes as types} from 'constants';
|
||||
import {LoginTypes, LogoutTypes} from 'constants';
|
||||
const types = {...LoginTypes, ...LogoutTypes};
|
||||
|
||||
export const initState = {
|
||||
status: 'not fetched',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {PostsTypes as types} from 'constants';
|
||||
import {PostsTypes, LogoutTypes} from 'constants';
|
||||
const types = {...PostsTypes, ...LogoutTypes};
|
||||
|
||||
export const initState = {
|
||||
status: 'not fetched',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {TeamsTypes as types} from 'constants';
|
||||
import {TeamsTypes, LogoutTypes} from 'constants';
|
||||
const types = {...TeamsTypes, ...LogoutTypes};
|
||||
|
||||
export const initState = {
|
||||
status: 'not fetched',
|
||||
|
|
|
|||
Loading…
Reference in a new issue