diff --git a/lib/reducers/policies-reducer.js b/lib/reducers/policies-reducer.js --- a/lib/reducers/policies-reducer.js +++ b/lib/reducers/policies-reducer.js @@ -2,7 +2,9 @@ import { siweAuthActionTypes } from '../actions/siwe-actions.js'; import { + deleteAccountActionTypes, logInActionTypes, + logOutActionTypes, policyAcknowledgmentActionTypes, } from '../actions/user-actions.js'; import type { PolicyType } from '../facts/policies.js'; @@ -34,8 +36,7 @@ }; }); return newState; - } - if (action.type === policyAcknowledgmentActionTypes.success) { + } else if (action.type === policyAcknowledgmentActionTypes.success) { const { policy } = action.payload; return { ...state, @@ -44,6 +45,12 @@ isAcknowledged: true, }, }; + } else if ( + action.type === logOutActionTypes.started || + action.type === logOutActionTypes.success || + action.type === deleteAccountActionTypes.success + ) { + return {}; } return state; } diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js --- a/lib/socket/socket.react.js +++ b/lib/socket/socket.react.js @@ -467,7 +467,7 @@ } else { console.log(`socket sent error ${errorMessage}`); } - if (errorMessage === 'policies_not_accepted') { + if (errorMessage === 'policies_not_accepted' && this.props.active) { this.props.dispatch({ type: forcePolicyAcknowledgmentActionType, payload, diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js --- a/lib/utils/action-utils.js +++ b/lib/utils/action-utils.js @@ -216,6 +216,7 @@ data, dispatch, options, + false, ); if (callServerEndpointCallback) { callServerEndpointCallback(!!newSessionChange); @@ -361,6 +362,7 @@ data, dispatch, options, + loggedIn, ); } diff --git a/lib/utils/call-server-endpoint.js b/lib/utils/call-server-endpoint.js --- a/lib/utils/call-server-endpoint.js +++ b/lib/utils/call-server-endpoint.js @@ -98,6 +98,7 @@ input: { [key: string]: mixed }, dispatch: Dispatch, options?: ?CallServerEndpointOptions, + loggedIn: boolean, ): Promise { const possibleReplacement = await waitIfCookieInvalidated(); if (possibleReplacement) { @@ -226,7 +227,7 @@ }); } - if (error === 'policies_not_accepted') { + if (error === 'policies_not_accepted' && loggedIn) { dispatch({ type: forcePolicyAcknowledgmentActionType, payload,