diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js --- a/lib/reducers/keyserver-reducer.js +++ b/lib/reducers/keyserver-reducer.js @@ -75,20 +75,29 @@ keyserverInfos, }; } else if (action.type === setNewSessionActionType) { - const { keyserverID } = action.payload; - if (action.payload.sessionChange.cookie !== undefined) { + const { keyserverID, sessionChange } = action.payload; + if (!state.keyserverInfos[keyserverID]) { + if (sessionChange.cookie?.startsWith('user=')) { + console.log( + 'received sessionChange with user cookie, ' + + `but keyserver ${keyserverID} is not in KeyserverStore!`, + ); + } + return state; + } + if (sessionChange.cookie !== undefined) { state = { ...state, keyserverInfos: { ...state.keyserverInfos, [keyserverID]: { ...state.keyserverInfos[keyserverID], - cookie: action.payload.sessionChange.cookie, + cookie: sessionChange.cookie, }, }, }; } - if (action.payload.sessionChange.cookieInvalidated) { + if (sessionChange.cookieInvalidated) { state = { ...state, keyserverInfos: { diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -164,12 +164,21 @@ storeOperations, ); } else if (action.type === setNewSessionActionType) { - const { keyserverID } = action.payload; + const { keyserverID, sessionChange } = action.payload; + if (!state.keyserverStore.keyserverInfos[keyserverID]) { + if (sessionChange.cookie?.startsWith('user=')) { + console.log( + 'received sessionChange with user cookie, ' + + `but keyserver ${keyserverID} is not in KeyserverStore!`, + ); + } + return state; + } if ( invalidSessionDowngrade( oldState, - action.payload.sessionChange.currentUserInfo, + sessionChange.currentUserInfo, action.payload.preRequestUserState, keyserverID, ) @@ -188,7 +197,7 @@ ...state.keyserverStore.keyserverInfos, [keyserverID]: { ...state.keyserverStore.keyserverInfos[keyserverID], - sessionID: action.payload.sessionChange.sessionID, + sessionID: sessionChange.sessionID, }, }, },