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 @@ -530,14 +530,25 @@ ) => Promise { const client = React.useContext(IdentityClientContext); const identityClient = client?.identityClient; + const preRequestUserState = useSelector(state => state.currentUserInfo); + return React.useCallback( (username, password) => { if (!identityClient) { throw new Error('Identity service client is not initialized'); } - return identityClient.logInPasswordUser(username, password); + return (async () => { + const result = await identityClient.logInPasswordUser( + username, + password, + ); + return { + ...result, + preRequestUserState: preRequestUserState, + }; + })(); }, - [identityClient], + [identityClient, preRequestUserState], ); } function useIdentityWalletLogIn(): ( diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -13,6 +13,10 @@ type OlmSessionInitializationInfo, olmSessionInitializationInfoValidator, } from './request-types.js'; +import { + currentUserInfoValidator, + type CurrentUserInfo, +} from './user-types.js'; import { tShape } from '../utils/validation-utils.js'; export type UserAuthMetadata = { @@ -152,12 +156,14 @@ +userID: string, +accessToken: string, +username: string, + +preRequestUserState: ?CurrentUserInfo, }; export const identityAuthResultValidator: TInterface = tShape({ userID: t.String, accessToken: t.String, username: t.String, + preRequestUserState: t.maybe(currentUserInfoValidator), }); export type IdentityNewDeviceKeyUpload = {