Navigate reglock mismatch to account locked in regV5.

This commit is contained in:
Greyson Parrelli
2026-07-14 16:14:00 -04:00
parent 693b208fe2
commit adad1425d8
2 changed files with 11 additions and 4 deletions
@@ -25,6 +25,7 @@ import org.signal.registration.RegistrationRoute
import org.signal.registration.screens.EventDrivenViewModel
import org.signal.registration.screens.util.navigateBack
import org.signal.registration.screens.util.navigateTo
import kotlin.time.Duration.Companion.days
/**
* ViewModel for the registration lock PIN entry screen.
@@ -173,8 +174,8 @@ class PinEntryForRegistrationLockViewModel(
state
}
is NetworkController.RegisterAccountError.RegistrationLock -> {
Log.w(TAG, "[PinEntered] Still getting registration lock error after providing token. This shouldn't happen. Resetting state.")
parentEventEmitter(RegistrationFlowEvent.ResetState)
Log.w(TAG, "[PinEntered] Still getting registration lock error after providing token. This implies that the MasterKey and reglock token on AccountAttributes is out of sync. All we can do is report the account as locked.")
parentEventEmitter.navigateTo(RegistrationRoute.AccountLocked(7.days.inWholeMilliseconds))
state
}
is NetworkController.RegisterAccountError.RateLimited -> {
@@ -27,6 +27,7 @@ import org.signal.registration.RegistrationFlowEvent
import org.signal.registration.RegistrationFlowState
import org.signal.registration.RegistrationRepository
import org.signal.registration.RegistrationRoute
import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.seconds
class PinEntryForRegistrationLockViewModelTest {
@@ -296,7 +297,7 @@ class PinEntryForRegistrationLockViewModelTest {
}
@Test
fun `PinEntered with registration lock error during registration emits ResetState`() = runTest {
fun `PinEntered with registration lock error during registration navigates to AccountLocked`() = runTest {
val masterKey = mockk<MasterKey>(relaxed = true)
val registrationLockData = mockk<NetworkController.RegistrationLockResponse>(relaxed = true)
val initialState = PinEntryState(mode = PinEntryState.Mode.RegistrationLock)
@@ -312,7 +313,12 @@ class PinEntryForRegistrationLockViewModelTest {
assertThat(emittedParentEvents).hasSize(2)
assertThat(emittedParentEvents[0]).isInstanceOf<RegistrationFlowEvent.MasterKeyRestoredFromSvr>()
assertThat(emittedParentEvents[1]).isEqualTo(RegistrationFlowEvent.ResetState)
assertThat(emittedParentEvents[1])
.isInstanceOf<RegistrationFlowEvent.NavigateToScreen>()
.prop(RegistrationFlowEvent.NavigateToScreen::route)
.isInstanceOf<RegistrationRoute.AccountLocked>()
.prop(RegistrationRoute.AccountLocked::timeRemainingMs)
.isEqualTo(7.days.inWholeMilliseconds)
}
@Test