@@ -90,10 +90,8 @@ import kotlinx.coroutines.launch
90
90
import kotlinx.coroutines.withContext
91
91
import org.jetbrains.annotations.VisibleForTesting
92
92
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) {
97
95
98
96
// Constructor for compose viewModels provider
99
97
constructor (application: Application ) : this (application, RealAuthProvider ())
@@ -363,22 +361,15 @@ internal class AuthenticatorViewModel(
363
361
)
364
362
}
365
363
366
- private suspend fun handleEmailMfaSetupRequired (
367
- username : String ,
368
- password : String
369
- ) {
364
+ private suspend fun handleEmailMfaSetupRequired (username : String , password : String ) {
370
365
moveTo(
371
366
stateFactory.newSignInContinueWithEmailSetupState(
372
367
onSubmit = { mfaType -> confirmSignIn(username, password, mfaType) }
373
368
)
374
369
)
375
370
}
376
371
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 >? ) {
382
373
if (allowedMfaTypes.isNullOrEmpty()) {
383
374
handleGeneralFailure(AuthException (" Missing allowedMfaTypes" , " Please open a bug with Amplify" ))
384
375
return
@@ -500,10 +491,7 @@ internal class AuthenticatorViewModel(
500
491
}.join()
501
492
}
502
493
503
- private suspend fun handleResetPasswordSuccess (
504
- username : String ,
505
- result : AuthResetPasswordResult
506
- ) {
494
+ private suspend fun handleResetPasswordSuccess (username : String , result : AuthResetPasswordResult ) {
507
495
when (result.nextStep.resetPasswordStep) {
508
496
AuthResetPasswordStep .DONE -> handlePasswordResetComplete()
509
497
AuthResetPasswordStep .CONFIRM_RESET_PASSWORD_WITH_CODE -> {
@@ -634,7 +622,10 @@ internal class AuthenticatorViewModel(
634
622
logger.error(" Current signed in user session has expired, signing out." )
635
623
signOut()
636
624
} else {
637
- handleGeneralFailure(result.error)
625
+ handleRetryableGeneralFailure(
626
+ error = result.error,
627
+ onRetry = { viewModelScope.launch { handleSignedIn() }.join() }
628
+ )
638
629
}
639
630
}
640
631
0 commit comments