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 @@ -444,11 +444,27 @@ calendarQuery: CalendarQuery, }; -const tempIdentityLoginActionTypes = Object.freeze({ - started: 'TEMP_IDENTITY_LOG_IN_STARTED', - success: 'TEMP_IDENTITY_LOG_IN_SUCCESS', - failed: 'TEMP_IDENTITY_LOG_IN_FAILED', +const identityLogInActionTypes = Object.freeze({ + started: 'IDENTITY_LOG_IN_STARTED', + success: 'IDENTITY_LOG_IN_SUCCESS', + failed: 'IDENTITY_LOG_IN_FAILED', }); +function useIdentityPasswordLogIn(): ( + username: string, + password: string, +) => Promise { + const client = React.useContext(IdentityClientContext); + const identityClient = client?.identityClient; + return React.useCallback( + (username, password) => { + if (!identityClient) { + throw new Error('Identity service client is not initialized'); + } + return identityClient.logInPasswordUser(username, password); + }, + [identityClient], + ); +} const logInActionTypes = Object.freeze({ started: 'LOG_IN_STARTED', @@ -741,7 +757,8 @@ getOlmSessionInitializationData, mergeUserInfos, logIn as logInRawAction, - tempIdentityLoginActionTypes, + identityLogInActionTypes, + useIdentityPasswordLogIn, useLogIn, logInActionTypes, useLogOut, 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 @@ -341,22 +341,6 @@ +payload: ?DeleteEntryResult, +loadingInfo: LoadingInfo, } - | { - +type: 'TEMP_IDENTITY_LOG_IN_STARTED', - +loadingInfo: LoadingInfo, - +payload?: void, - } - | { - +type: 'TEMP_IDENTITY_LOG_IN_FAILED', - +error: true, - +payload: Error, - +loadingInfo: LoadingInfo, - } - | { - +type: 'TEMP_IDENTITY_LOG_IN_SUCCESS', - +payload?: void, - +loadingInfo: LoadingInfo, - } | { +type: 'KEYSERVER_AUTH_STARTED', +loadingInfo: LoadingInfo,