mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 19:28:44 +03:00
Remove references to HTTP constants in favor of raw ints (#167)
This commit is contained in:
parent
fd9ba2550f
commit
865a99fd67
2 changed files with 5 additions and 9 deletions
|
@ -8,7 +8,6 @@ import com.x8bit.bitwarden.data.auth.datasource.network.model.RegisterResponseJs
|
|||
import com.x8bit.bitwarden.data.platform.datasource.network.model.toBitwardenError
|
||||
import com.x8bit.bitwarden.data.platform.datasource.network.util.parseErrorBodyOrNull
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.net.HttpURLConnection
|
||||
|
||||
class AccountsServiceImpl constructor(
|
||||
private val accountsApi: AccountsApi,
|
||||
|
@ -25,13 +24,10 @@ class AccountsServiceImpl constructor(
|
|||
.recoverCatching { throwable ->
|
||||
val bitwardenError = throwable.toBitwardenError()
|
||||
bitwardenError.parseErrorBodyOrNull<RegisterResponseJson.CaptchaRequired>(
|
||||
code = HttpURLConnection.HTTP_BAD_REQUEST,
|
||||
code = 400,
|
||||
json = json,
|
||||
) ?: bitwardenError.parseErrorBodyOrNull<RegisterResponseJson.Invalid>(
|
||||
codes = listOf(
|
||||
HttpURLConnection.HTTP_BAD_REQUEST,
|
||||
429,
|
||||
),
|
||||
codes = listOf(400, 429),
|
||||
json = json,
|
||||
) ?: bitwardenError.parseErrorBodyOrNull<RegisterResponseJson.Error>(
|
||||
code = 429,
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.x8bit.bitwarden.data.platform.datasource.network.util.base64UrlEncode
|
|||
import com.x8bit.bitwarden.data.platform.datasource.network.util.parseErrorBodyOrNull
|
||||
import com.x8bit.bitwarden.data.platform.util.DeviceModelProvider
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.net.HttpURLConnection.HTTP_BAD_REQUEST
|
||||
import java.util.UUID
|
||||
|
||||
class IdentityServiceImpl constructor(
|
||||
|
@ -16,6 +15,7 @@ class IdentityServiceImpl constructor(
|
|||
private val deviceModelProvider: DeviceModelProvider = DeviceModelProvider(),
|
||||
) : IdentityService {
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
override suspend fun getToken(
|
||||
email: String,
|
||||
passwordHash: String,
|
||||
|
@ -37,10 +37,10 @@ class IdentityServiceImpl constructor(
|
|||
.recoverCatching { throwable ->
|
||||
val bitwardenError = throwable.toBitwardenError()
|
||||
bitwardenError.parseErrorBodyOrNull<GetTokenResponseJson.CaptchaRequired>(
|
||||
code = HTTP_BAD_REQUEST,
|
||||
code = 400,
|
||||
json = json,
|
||||
) ?: bitwardenError.parseErrorBodyOrNull<GetTokenResponseJson.Invalid>(
|
||||
code = HTTP_BAD_REQUEST,
|
||||
code = 400,
|
||||
json = json,
|
||||
) ?: throw throwable
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue