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 @@ -431,6 +431,28 @@ failed: 'TEMP_IDENTITY_LOG_IN_FAILED', }); +const identityPasswordLogInActionTypes = Object.freeze({ + started: 'IDENTITY_PASSWORD_LOG_IN_STARTED', + success: 'IDENTITY_PASSWORD_LOG_IN_SUCCESS', + failed: 'IDENTITY_PASSWORD_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', success: 'LOG_IN_SUCCESS', @@ -723,6 +745,8 @@ mergeUserInfos, logIn as logInRawAction, tempIdentityLoginActionTypes, + identityPasswordLogInActionTypes, + useIdentityPasswordLogIn, useLogIn, logInActionTypes, useLogOut,