mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix changing number flow in scenarios where service requires additional verification.
Fixes #12985, #13059.
This commit is contained in:
committed by
Clark Chen
parent
e7e00bd428
commit
fddfbd8d2d
@@ -81,7 +81,7 @@ class ChangeNumberVerifyFragment : LoggingFragment(R.layout.fragment_change_phon
|
||||
|
||||
val processor: RegistrationSessionProcessor = (result as RequestCodeResult.RequestedVerificationCode).processor
|
||||
|
||||
if (processor.hasResult()) {
|
||||
if (processor.verificationCodeRequestSuccess()) {
|
||||
Log.i(TAG, "Successfully requested SMS code.")
|
||||
findNavController().safeNavigate(R.id.action_changePhoneNumberVerifyFragment_to_changeNumberEnterCodeFragment)
|
||||
} else if (processor.captchaRequired(viewModel.excludedChallenges)) {
|
||||
|
||||
@@ -88,6 +88,12 @@ sealed class RegistrationSessionProcessor(response: ServiceResponse<Registration
|
||||
return 0 == result.body.nextVerificationAttempt
|
||||
}
|
||||
|
||||
fun mustWaitToSubmitProof(): Boolean {
|
||||
Preconditions.checkState(hasResult(), "This can only be called when result is present!")
|
||||
val nextVerificationAttempt = result.body.nextVerificationAttempt
|
||||
return nextVerificationAttempt != null && nextVerificationAttempt > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* The soonest time at which the server will accept a submission of proof of ownership.
|
||||
* @return a unix timestamp in milliseconds, or 0 to represent null
|
||||
@@ -149,7 +155,17 @@ sealed class RegistrationSessionProcessor(response: ServiceResponse<Registration
|
||||
}
|
||||
|
||||
fun cannotSubmitVerificationAttempt(): Boolean {
|
||||
return !hasResult() || result.body.nextVerificationAttempt == null
|
||||
if (!hasResult()) {
|
||||
return true
|
||||
}
|
||||
|
||||
val body = result.body
|
||||
|
||||
if (body.requestedInformation.isNotEmpty()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return body.nextVerificationAttempt == null
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -389,12 +389,16 @@ public abstract class BaseEnterSmsCodeFragment<ViewModel extends BaseRegistratio
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(processor -> {
|
||||
if (!processor.hasResult()) {
|
||||
Log.d(TAG, "Network error.");
|
||||
returnToPhoneEntryScreen();
|
||||
} else if (processor.isInvalidSession()) {
|
||||
Log.d(TAG, "Registration session is invalid.");
|
||||
returnToPhoneEntryScreen();
|
||||
} else if (processor.cannotSubmitVerificationAttempt()) {
|
||||
Log.d(TAG, "Cannot submit any more verification attempts.");
|
||||
returnToPhoneEntryScreen();
|
||||
} else if (!processor.canSubmitProofImmediately()) {
|
||||
} else if (processor.mustWaitToSubmitProof()) {
|
||||
Log.d(TAG, "Blocked from submitting proof at this time.");
|
||||
handleRateLimited();
|
||||
}
|
||||
// else session state is valid and server is ready to accept code
|
||||
|
||||
Reference in New Issue
Block a user