diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -1475,6 +1475,12 @@ }; } +const identityRestoreActionTypes = Object.freeze({ + started: 'IDENTITY_RESTORE_STARTED', + success: 'IDENTITY_RESTORE_SUCCESS', + failed: 'IDENTITY_RESTORE_FAILED', +}); + export { changeKeyserverUserPasswordActionTypes, changeKeyserverUserPassword, @@ -1527,4 +1533,5 @@ versionSupportedByIdentityActionTypes, useVersionSupportedByIdentity, useInvalidCSATLogOut, + identityRestoreActionTypes, }; 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 @@ -24,6 +24,7 @@ deleteAccountActionTypes, legacyKeyserverRegisterActionTypes, legacyLogInActionTypes, + identityRestoreActionTypes, } from '../actions/user-actions.js'; import { extractKeyserverIDFromIDOptional } from '../keyserver-conn/keyserver-call-utils.js'; import { @@ -515,6 +516,7 @@ action.type === logOutActionTypes.success || action.type === deleteAccountActionTypes.success || action.type === identityRegisterActionTypes.success || + action.type === identityRestoreActionTypes.success || (action.type === identityLogInActionTypes.success && action.payload.userID !== action.payload.preRequestUserState?.id) ) { diff --git a/lib/reducers/nav-reducer.js b/lib/reducers/nav-reducer.js --- a/lib/reducers/nav-reducer.js +++ b/lib/reducers/nav-reducer.js @@ -9,6 +9,7 @@ logOutActionTypes, deleteAccountActionTypes, identityLogInActionTypes, + identityRestoreActionTypes, } from '../actions/user-actions.js'; import { defaultCalendarQuery } from '../types/entry-types.js'; import type { BaseNavInfo } from '../types/nav-types.js'; @@ -47,6 +48,7 @@ action.type === logOutActionTypes.success || action.type === deleteAccountActionTypes.success || action.type === identityRegisterActionTypes.success || + action.type === identityRestoreActionTypes.success || (action.type === identityLogInActionTypes.success && action.payload.userID !== action.payload.preRequestUserState?.id) ) { diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js --- a/lib/reducers/user-reducer.js +++ b/lib/reducers/user-reducer.js @@ -23,6 +23,7 @@ legacyKeyserverRegisterActionTypes, setUserSettingsActionTypes, updateUserAvatarActionTypes, + identityRestoreActionTypes, } from '../actions/user-actions.js'; import { extractKeyserverIDFromIDOptional } from '../keyserver-conn/keyserver-call-utils.js'; import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js'; @@ -81,6 +82,7 @@ ): ?CurrentUserInfo { if ( action.type === identityLogInActionTypes.success || + action.type === identityRestoreActionTypes.success || action.type === identityRegisterActionTypes.success ) { const newUserInfo = { diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -1660,6 +1660,22 @@ +error: true, +payload: Error, +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_RESTORE_STARTED', + +loadingInfo: LoadingInfo, + +payload?: void, + } + | { + +type: 'IDENTITY_RESTORE_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'IDENTITY_RESTORE_SUCCESS', + +payload: IdentityAuthResult, + +loadingInfo: LoadingInfo, }, }>; diff --git a/web/redux/services-access-token-reducer.js b/web/redux/services-access-token-reducer.js --- a/web/redux/services-access-token-reducer.js +++ b/web/redux/services-access-token-reducer.js @@ -3,6 +3,7 @@ import { identityLogInActionTypes, identityRegisterActionTypes, + identityRestoreActionTypes, } from 'lib/actions/user-actions.js'; import type { Action } from './redux-setup.js'; @@ -10,6 +11,7 @@ function reduceServicesAccessToken(state: ?string, action: Action): ?string { if ( action.type === identityLogInActionTypes.success || + action.type === identityRestoreActionTypes.success || action.type === identityRegisterActionTypes.success ) { return action.payload.accessToken;