Keep newly created account disabled until SMS code validation is done

This commit is contained in:
Sylvain Berfini 2025-03-25 16:54:19 +01:00
parent a503ef06ee
commit a0108776dd

View file

@ -142,14 +142,7 @@ class AccountCreationViewModel
goToSmsCodeConfirmationViewEvent.postValue(Event(true))
}
AccountManagerServicesRequest.Type.LinkPhoneNumberUsingCode -> {
val account = accountCreated
if (account != null) {
Log.i(
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] has been created & activated, setting it as default"
)
coreContext.core.defaultAccount = account
}
accountCreatedEvent.postValue(Event(true))
enableAccountAndSetItAsDefault()
}
else -> { }
}
@ -496,6 +489,9 @@ class AccountCreationViewModel
)
accountParams.internationalPrefix = dialPlan.internationalCallPrefix
accountParams.internationalPrefixIsoCountryCode = dialPlan.isoCountryCode
// Do not enable account just yet, wait for it to be activated using SMS code
accountParams.isRegisterEnabled = false
}
val account = core.createAccount(accountParams)
core.addAccount(account)
@ -507,6 +503,21 @@ class AccountCreationViewModel
lockUsernameAndPassword.postValue(true)
}
@WorkerThread
private fun enableAccountAndSetItAsDefault() {
val account = accountCreated ?: return
Log.i(
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] has been created & activated, enable it & setting it as default"
)
val newParams = account.params.clone()
newParams.isRegisterEnabled = true
account.params = newParams
coreContext.core.defaultAccount = account
accountCreatedEvent.postValue(Event(true))
}
@WorkerThread
private fun requestFlexiApiToken() {
if (!coreContext.core.isPushNotificationAvailable) {