Update the TwoFactorRequired response to be able to parse multiple payload types (#1018)

This commit is contained in:
David Perez
2024-02-15 10:28:34 -06:00
committed by Álison Fernandes
parent d6513a1ef7
commit cb20a6d690
6 changed files with 42 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ package com.x8bit.bitwarden.data.auth.datasource.network.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
/**
* Models response bodies from the get token request.
@@ -121,7 +122,7 @@ sealed class GetTokenResponseJson {
@Serializable
data class TwoFactorRequired(
@SerialName("TwoFactorProviders2")
val authMethodsData: Map<TwoFactorAuthMethod, Map<String, String?>?>,
val authMethodsData: Map<TwoFactorAuthMethod, JsonObject?>,
@SerialName("CaptchaBypassToken")
val captchaToken: String?,

View File

@@ -2,6 +2,8 @@ package com.x8bit.bitwarden.data.auth.datasource.network.util
import com.x8bit.bitwarden.data.auth.datasource.network.model.GetTokenResponseJson
import com.x8bit.bitwarden.data.auth.datasource.network.model.TwoFactorAuthMethod
import kotlinx.serialization.json.contentOrNull
import kotlinx.serialization.json.jsonPrimitive
/**
* Return the list of two-factor auth methods available to the user.
@@ -34,4 +36,6 @@ val GetTokenResponseJson.TwoFactorRequired?.twoFactorDisplayEmail: String
?.authMethodsData
?.get(TwoFactorAuthMethod.EMAIL)
?.get("Email")
?.jsonPrimitive
?.contentOrNull
?: ""