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 @@ -322,6 +322,8 @@ const resetUserStateActionType = 'RESET_USER_STATE'; +const setAccessTokenActionType = 'SET_ACCESS_TOKEN'; + export { changeUserPasswordActionTypes, changeUserPassword, @@ -350,4 +352,5 @@ updateUserAvatarActionTypes, updateUserAvatar, resetUserStateActionType, + setAccessTokenActionType, }; diff --git a/lib/reducers/services-access-token-reducer.js b/lib/reducers/services-access-token-reducer.js --- a/lib/reducers/services-access-token-reducer.js +++ b/lib/reducers/services-access-token-reducer.js @@ -1,11 +1,9 @@ // @flow -import { siweAuthActionTypes } from '../actions/siwe-actions.js'; import { logOutActionTypes, deleteAccountActionTypes, - logInActionTypes, - registerActionTypes, + setAccessTokenActionType, } from '../actions/user-actions.js'; import type { BaseAction } from '../types/redux-types.js'; import { setNewSessionActionType } from '../utils/action-utils.js'; @@ -14,12 +12,8 @@ state: ?string, action: BaseAction, ): ?string { - if ( - action.type === logInActionTypes.success || - action.type === siweAuthActionTypes.success || - action.type === registerActionTypes.success - ) { - return null; + if (action.type === setAccessTokenActionType) { + return action.payload; } else if ( action.type === setNewSessionActionType && action.payload.sessionChange.currentUserInfo && 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 @@ -1190,6 +1190,10 @@ +error: true, +payload: Error, +loadingInfo: LoadingInfo, + } + | { + +type: 'SET_ACCESS_TOKEN', + +payload: string, }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);