adding dedicated fail event in the legacy onboarding flow when the reset password new password is not set

This commit is contained in:
Adam Brown 2022-05-30 13:35:06 +01:00
parent 32389a9b33
commit fa5b7c66ca

View File

@ -531,9 +531,17 @@ class LoginViewModel @AssistedInject constructor(
}
currentJob = viewModelScope.launch {
try {
val state = awaitState()
safeLoginWizard.resetPasswordMailConfirmed(state.resetPasswordNewPassword!!)
if (state.resetPasswordNewPassword == null)
setState {
copy(
asyncResetPassword = Uninitialized,
asyncResetMailConfirmed = Fail(Throwable("Developer error - New password not set"))
)
} else {
try {
safeLoginWizard.resetPasswordMailConfirmed(state.resetPasswordNewPassword)
} catch (failure: Throwable) {
setState {
copy(
@ -549,11 +557,11 @@ class LoginViewModel @AssistedInject constructor(
resetPasswordNewPassword = null
)
}
_viewEvents.post(LoginViewEvents.OnResetPasswordMailConfirmationSuccess)
}
}
}
}
private fun handleLoginOrRegister(action: LoginAction.LoginOrRegister) = withState { state ->
when (state.signMode) {