@@ -90,10 +90,8 @@ import kotlinx.coroutines.launch
9090import kotlinx.coroutines.withContext
9191import org.jetbrains.annotations.VisibleForTesting
9292
93- internal class AuthenticatorViewModel (
94- application : Application ,
95- private val authProvider : AuthProvider
96- ) : AndroidViewModel(application) {
93+ internal class AuthenticatorViewModel (application : Application , private val authProvider : AuthProvider ) :
94+ AndroidViewModel (application) {
9795
9896 // Constructor for compose viewModels provider
9997 constructor (application: Application ) : this (application, RealAuthProvider ())
@@ -363,22 +361,15 @@ internal class AuthenticatorViewModel(
363361 )
364362 }
365363
366- private suspend fun handleEmailMfaSetupRequired (
367- username : String ,
368- password : String
369- ) {
364+ private suspend fun handleEmailMfaSetupRequired (username : String , password : String ) {
370365 moveTo(
371366 stateFactory.newSignInContinueWithEmailSetupState(
372367 onSubmit = { mfaType -> confirmSignIn(username, password, mfaType) }
373368 )
374369 )
375370 }
376371
377- private suspend fun handleMfaSelectionRequired (
378- username : String ,
379- password : String ,
380- allowedMfaTypes : Set <MFAType >?
381- ) {
372+ private suspend fun handleMfaSelectionRequired (username : String , password : String , allowedMfaTypes : Set <MFAType >? ) {
382373 if (allowedMfaTypes.isNullOrEmpty()) {
383374 handleGeneralFailure(AuthException (" Missing allowedMfaTypes" , " Please open a bug with Amplify" ))
384375 return
@@ -500,10 +491,7 @@ internal class AuthenticatorViewModel(
500491 }.join()
501492 }
502493
503- private suspend fun handleResetPasswordSuccess (
504- username : String ,
505- result : AuthResetPasswordResult
506- ) {
494+ private suspend fun handleResetPasswordSuccess (username : String , result : AuthResetPasswordResult ) {
507495 when (result.nextStep.resetPasswordStep) {
508496 AuthResetPasswordStep .DONE -> handlePasswordResetComplete()
509497 AuthResetPasswordStep .CONFIRM_RESET_PASSWORD_WITH_CODE -> {
@@ -634,7 +622,10 @@ internal class AuthenticatorViewModel(
634622 logger.error(" Current signed in user session has expired, signing out." )
635623 signOut()
636624 } else {
637- handleGeneralFailure(result.error)
625+ handleRetryableGeneralFailure(
626+ error = result.error,
627+ onRetry = { viewModelScope.launch { handleSignedIn() }.join() }
628+ )
638629 }
639630 }
640631
0 commit comments