OTP page to show real name

This commit is contained in:
2026-05-15 11:53:51 +05:00
parent feb5b41f8b
commit 7c0ffece35
6 changed files with 213 additions and 14 deletions
@@ -190,20 +190,32 @@ class BmlLoginFlow {
return parseForeignLimits(json ?: return emptyList())
}
fun fetchUserInfo(session: BmlSession): String {
data class BmlUserInfo(
val fullName: String,
val email: String,
val mobile: String,
val customerId: String,
val idCard: String,
val birthdate: String
)
fun fetchUserInfo(session: BmlSession): BmlUserInfo? {
val resp = apiClient.newCall(apiRequest(session, "$BASE_URL/api/mobile/userinfo")).execute()
val json = resp.body?.string() ?: return ""
val json = resp.body?.string() ?: return null
resp.close()
return try {
val root = JSONObject(json)
if (!root.optBoolean("success")) return ""
val payload = root.optJSONObject("payload") ?: return ""
payload.optString("name").ifBlank {
payload.optString("fullName").ifBlank {
payload.optString("customer_name")
}
}
} catch (_: Exception) { "" }
if (!root.optBoolean("success")) return null
val user = root.optJSONObject("payload")?.optJSONObject("user") ?: return null
BmlUserInfo(
fullName = user.optString("fullname").trim(),
email = user.optString("email").trim(),
mobile = user.optString("mobile_phone").trim(),
customerId = user.optString("customer_number").trim(),
idCard = user.optString("idcard").trim(),
birthdate = user.optString("birthdate").trim()
)
} catch (_: Exception) { null }
}
fun validateAccount(session: BmlSession, input: String): BmlAccountValidation? {