Only submit captcha once in Registration V2.

This commit is contained in:
Nicholas Tinsley 2024-06-06 21:33:44 -04:00 committed by Cody Henthorne
parent fdf858f379
commit e6a126d416

View file

@ -373,14 +373,16 @@ class RegistrationV2ViewModel : ViewModel() {
val e164 = getCurrentE164() ?: throw IllegalStateException("Can't submit captcha token if no phone number is set!")
val captchaToken = store.value.captchaToken ?: throw IllegalStateException("Can't submit captcha token if no captcha token is set!")
store.update {
it.copy(captchaToken = null)
}
viewModelScope.launch {
val session = getOrCreateValidSession(context, errorHandler) ?: return@launch bail { Log.i(TAG, "Could not create valid session for submitting a captcha token.") }
Log.d(TAG, "Submitting captcha token…")
val captchaSubmissionResult = RegistrationRepository.submitCaptchaToken(context, e164, password, session.body.id, captchaToken)
Log.d(TAG, "Captcha token submitted.")
store.update {
it.copy(captchaToken = null)
}
handleSessionStateResult(context, captchaSubmissionResult, errorHandler)
}
}