mirror of
https://github.com/bitwarden/android.git
synced 2026-06-03 19:27:07 -05:00
Update the TwoFactorRequired response to be able to parse multiple payload types (#1018)
This commit is contained in:
committed by
Álison Fernandes
parent
d6513a1ef7
commit
cb20a6d690
@@ -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?,
|
||||
|
||||
@@ -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
|
||||
?: ""
|
||||
|
||||
Reference in New Issue
Block a user