diff --git a/frontend/src/store/application/index.js b/frontend/src/store/application/index.js index 3fe40cbf9e..7756af56e2 100644 --- a/frontend/src/store/application/index.js +++ b/frontend/src/store/application/index.js @@ -1,6 +1,6 @@ import { fromJS, List, Map } from 'immutable'; import { RECEIVE_ALL_APPLICATIONS, RECEIVE_APPLICATION } from './actions'; -import { USER_LOGOUT, UPDATE_USER } from '../user/actions'; +import { USER_LOGOUT, USER_LOGIN } from '../user/actions'; function getInitState() { return fromJS({ list: [], apps: {} }); @@ -13,7 +13,7 @@ const store = (state = getInitState(), action) => { case RECEIVE_ALL_APPLICATIONS: return state.set('list', new List(action.value.applications)); case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: return state; diff --git a/frontend/src/store/archive-store.js b/frontend/src/store/archive-store.js index a3453fccbb..ea3d329d07 100644 --- a/frontend/src/store/archive-store.js +++ b/frontend/src/store/archive-store.js @@ -1,6 +1,6 @@ import { List, Map as $Map } from 'immutable'; import { RECEIVE_ARCHIVE, REVIVE_TOGGLE } from './archive-actions'; -import { USER_LOGOUT, UPDATE_USER } from './user/actions'; +import { USER_LOGOUT, USER_LOGIN } from './user/actions'; function getInitState() { return new $Map({ list: new List() }); @@ -13,7 +13,7 @@ const archiveStore = (state = getInitState(), action) => { case RECEIVE_ARCHIVE: return state.set('list', new List(action.value)); case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: return state; diff --git a/frontend/src/store/client-instance-store.js b/frontend/src/store/client-instance-store.js index e65eab6233..8f5c175952 100644 --- a/frontend/src/store/client-instance-store.js +++ b/frontend/src/store/client-instance-store.js @@ -1,6 +1,6 @@ import { fromJS } from 'immutable'; import { RECEIVE_CLIENT_INSTANCES } from './client-instance-actions'; -import { USER_LOGOUT, UPDATE_USER } from './user/actions'; +import { USER_LOGOUT, USER_LOGIN } from './user/actions'; function getInitState() { return fromJS([]); @@ -11,7 +11,7 @@ const store = (state = getInitState(), action) => { case RECEIVE_CLIENT_INSTANCES: return fromJS(action.value); case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: return state; diff --git a/frontend/src/store/context/index.js b/frontend/src/store/context/index.js index 3b56012bcd..a70ea14d9a 100644 --- a/frontend/src/store/context/index.js +++ b/frontend/src/store/context/index.js @@ -1,6 +1,6 @@ import { List } from 'immutable'; import { RECEIVE_CONTEXT, REMOVE_CONTEXT, ADD_CONTEXT_FIELD, UPDATE_CONTEXT_FIELD } from './actions'; -import { USER_LOGOUT, UPDATE_USER } from '../user/actions'; +import { USER_LOGOUT, USER_LOGIN } from '../user/actions'; const DEFAULT_CONTEXT_FIELDS = [{ name: 'environment' }, { name: 'userId' }, { name: 'appName' }]; @@ -21,7 +21,7 @@ const strategies = (state = getInitState(), action) => { return state.set(index, action.context); } case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: return state; diff --git a/frontend/src/store/feature-store.js b/frontend/src/store/feature-store.js index 9120633a2a..eb004d855f 100644 --- a/frontend/src/store/feature-store.js +++ b/frontend/src/store/feature-store.js @@ -10,7 +10,7 @@ import { TOGGLE_FEATURE_TOGGLE, } from './feature-actions'; -import { USER_LOGOUT, UPDATE_USER } from './user/actions'; +import { USER_LOGOUT, USER_LOGIN } from './user/actions'; const features = (state = new List([]), action) => { switch (action.type) { @@ -50,7 +50,7 @@ const features = (state = new List([]), action) => { case RECEIVE_FEATURE_TOGGLES: debug(RECEIVE_FEATURE_TOGGLES, action); return new List(action.featureToggles.map($Map)); - case UPDATE_USER: + case USER_LOGIN: case USER_LOGOUT: debug(USER_LOGOUT, action); return new List([]); diff --git a/frontend/src/store/history-store.js b/frontend/src/store/history-store.js index b3ed5807b9..05b2587a56 100644 --- a/frontend/src/store/history-store.js +++ b/frontend/src/store/history-store.js @@ -1,6 +1,6 @@ import { List, Map as $Map } from 'immutable'; import { RECEIVE_HISTORY, RECEIVE_HISTORY_FOR_TOGGLE } from './history-actions'; -import { USER_LOGOUT, UPDATE_USER } from './user/actions'; +import { USER_LOGOUT, USER_LOGIN } from './user/actions'; function getInitState() { return new $Map({ list: new List(), toggles: new $Map() }); @@ -13,7 +13,7 @@ const historyStore = (state = getInitState(), action) => { case RECEIVE_HISTORY: return state.set('list', new List(action.value)); case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: return state; diff --git a/frontend/src/store/input-store.js b/frontend/src/store/input-store.js index a594c4e5b3..d22addc586 100644 --- a/frontend/src/store/input-store.js +++ b/frontend/src/store/input-store.js @@ -1,6 +1,6 @@ import { Map as $Map, List, fromJS } from 'immutable'; import actions from './input-actions'; -import { USER_LOGOUT, UPDATE_USER } from './user/actions'; +import { USER_LOGOUT, USER_LOGIN } from './user/actions'; function getInitState() { return new $Map(); @@ -103,7 +103,7 @@ const inputState = (state = getInitState(), action) => { case actions.CLEAR: return clear(state, action); case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: // console.log('TYPE', action.type, action); diff --git a/frontend/src/store/settings/index.js b/frontend/src/store/settings/index.js index 1f5a0024e4..35d1fd8c1e 100644 --- a/frontend/src/store/settings/index.js +++ b/frontend/src/store/settings/index.js @@ -1,6 +1,6 @@ import { fromJS, Map as $Map } from 'immutable'; import { UPDATE_SETTING } from './actions'; -import { USER_LOGOUT, UPDATE_USER } from '../user/actions'; +import { USER_LOGOUT, USER_LOGIN } from '../user/actions'; // TODO: provde a mock if localstorage does not exists? const localStorage = window.localStorage || {}; @@ -27,7 +27,7 @@ const settingStore = (state = getInitState(), action) => { case UPDATE_SETTING: return updateSetting(state, action); case USER_LOGOUT: - case UPDATE_USER: + case USER_LOGIN: return getInitState(); default: return state; diff --git a/frontend/src/store/user/actions.js b/frontend/src/store/user/actions.js index cd47bf68d6..949562dcc9 100644 --- a/frontend/src/store/user/actions.js +++ b/frontend/src/store/user/actions.js @@ -2,6 +2,7 @@ import api from '../../data/user-api'; import { dispatchAndThrow } from '../util'; export const UPDATE_USER = 'UPDATE_USER'; export const USER_LOGOUT = 'USER_LOGOUT'; +export const USER_LOGIN = 'USER_LOGIN'; export const START_FETCH_USER = 'START_FETCH_USER'; export const ERROR_FETCH_USER = 'ERROR_FETCH_USER'; const debug = require('debug')('unleash:user-actions'); @@ -42,7 +43,10 @@ export function passwordLogin(path, user) { return dispatch => { dispatch({ type: START_FETCH_USER }); - return api.passwordLogin(path, user).then(json => dispatch(updateUser(json))); + return api + .passwordLogin(path, user) + .then(json => dispatch(updateUser(json))) + .then(() => dispatch({ type: USER_LOGIN })); }; }