Recovering a Customer account
This guide shows how a Customer can recover their account using phone number and OTP verification with Android APIs and models.
Prerequisites
- SDK initialized and configured. See: Android VipasoSDK
1) Start Recovery Flow
Initiate the recovery flow with the user's phone number. This triggers an OTP to the provided number.
import io.vipaso.vipaso.sdkApi.user.customer.request.StartRecoveryRequest
import io.vipaso.vipaso.sdkApi.user.customer.response.StartRecoveryResponse
val request = StartRecoveryRequest(phoneNumber = "+1234567890")
val response: StartRecoveryResponse = Vipaso.user.customer.startRecoveryFlow(request)
// response.flowId will be needed in the next step
2) Verify Recovery OTP
Verify the OTP code sent to the user's phone using the flowId
from the previous step.
import io.vipaso.vipaso.sdkApi.user.customer.response.RecoveryOtpResponse
val recoveryOtpResponse: RecoveryOtpResponse = Vipaso.user.customer.verifyRecoveryOtp(
flowId = response.flowId,
otpCode = "123456"
)
// If needed, you can store intermediate data from recoveryOtpResponse
3) Finalize Recovery Flow
Complete the recovery by setting the new password.
import io.vipaso.vipaso.sdkApi.user.customer.request.UpdatePasswordRequest
val passwordRequest = UpdatePasswordRequest(
settingFlowId = "settings-flow-abc",
sessionToken = "session-token-xyz",
password = "new_secure_password"
)
Vipaso.user.customer.finalizeRecoveryFlow(passwordRequest)
// On success, the session is updated if applicable