@@ -672,14 +672,14 @@ internal class AuthenticatorViewModel(
672672 logger.debug(" Confirming password reset" )
673673 when (val result = authProvider.confirmResetPassword(username, password, code)) {
674674 is AmplifyResult .Error -> handleResetPasswordError(result.error)
675- is AmplifyResult .Success -> handlePasswordResetComplete()
675+ is AmplifyResult .Success -> handlePasswordResetComplete(username, password )
676676 }
677677 }.join()
678678 }
679679
680680 private suspend fun handleResetPasswordSuccess (username : String , result : AuthResetPasswordResult ) {
681681 when (result.nextStep.resetPasswordStep) {
682- AuthResetPasswordStep .DONE -> handlePasswordResetComplete()
682+ AuthResetPasswordStep .DONE -> handlePasswordResetComplete(null , null )
683683 AuthResetPasswordStep .CONFIRM_RESET_PASSWORD_WITH_CODE -> {
684684 logger.debug(" Password reset confirmation required" )
685685 val state = stateFactory.newResetPasswordConfirmState(
@@ -696,10 +696,27 @@ internal class AuthenticatorViewModel(
696696 }
697697 }
698698
699- private suspend fun handlePasswordResetComplete () {
699+ private suspend fun handlePasswordResetComplete (username : String? , password : String? ) {
700700 logger.debug(" Password reset complete" )
701701 sendMessage(PasswordResetMessage )
702- moveTo(stateFactory.newSignInState(this ::signIn))
702+ if (username != null && password != null ) {
703+ startSignInJob {
704+ val options = getSignInOptions(AuthFactor .Password (srp = true ))
705+ when (val result = authProvider.signIn(username, password, options)) {
706+ is AmplifyResult .Error -> moveTo(stateFactory.newSignInState(this ::signIn))
707+ is AmplifyResult .Success -> {
708+ val info = UserInfo (
709+ username = username,
710+ password = password,
711+ signInSource = SignInSource .SignIn
712+ )
713+ handleSignInSuccess(info, result.data)
714+ }
715+ }
716+ }
717+ } else {
718+ moveTo(stateFactory.newSignInState(this ::signIn))
719+ }
703720 }
704721
705722 private suspend fun handleResetPasswordError (error : AuthException ) = handleAuthException(error)
0 commit comments