mirror of
https://github.com/bitwarden/android.git
synced 2026-06-04 11:46:51 -05:00
Create AccountTokensJson for reusability (#1035)
This commit is contained in:
committed by
Álison Fernandes
parent
e45c1034a5
commit
2d54fc4616
@@ -18,7 +18,7 @@ data class AccountJson(
|
||||
val profile: Profile,
|
||||
|
||||
@SerialName("tokens")
|
||||
val tokens: Tokens,
|
||||
val tokens: AccountTokensJson,
|
||||
|
||||
@SerialName("settings")
|
||||
val settings: Settings,
|
||||
@@ -91,21 +91,6 @@ data class AccountJson(
|
||||
val userDecryptionOptions: UserDecryptionOptionsJson?,
|
||||
)
|
||||
|
||||
/**
|
||||
* Container for the user's API tokens.
|
||||
*
|
||||
* @property accessToken The user's primary access token.
|
||||
* @property refreshToken The user's refresh token.
|
||||
*/
|
||||
@Serializable
|
||||
data class Tokens(
|
||||
@SerialName("accessToken")
|
||||
val accessToken: String?,
|
||||
|
||||
@SerialName("refreshToken")
|
||||
val refreshToken: String?,
|
||||
)
|
||||
|
||||
/**
|
||||
* Container for various user settings.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.x8bit.bitwarden.data.auth.datasource.disk.model
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Container for the user's API tokens.
|
||||
*
|
||||
* @property accessToken The user's primary access token.
|
||||
* @property refreshToken The user's refresh token.
|
||||
*/
|
||||
@Serializable
|
||||
data class AccountTokensJson(
|
||||
@SerialName("accessToken")
|
||||
val accessToken: String?,
|
||||
|
||||
@SerialName("refreshToken")
|
||||
val refreshToken: String?,
|
||||
)
|
||||
@@ -5,7 +5,7 @@ import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
||||
import com.x8bit.bitwarden.data.platform.datasource.disk.PushDiskSource
|
||||
import com.x8bit.bitwarden.data.platform.datasource.disk.SettingsDiskSource
|
||||
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
||||
@@ -77,7 +77,7 @@ class UserLogoutManagerImpl(
|
||||
.accounts[userId]
|
||||
// Clear the tokens for the current user if present
|
||||
?.copy(
|
||||
tokens = AccountJson.Tokens(
|
||||
tokens = AccountTokensJson(
|
||||
accessToken = null,
|
||||
refreshToken = null,
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.x8bit.bitwarden.data.auth.repository.util
|
||||
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.EnvironmentUrlDataJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.ForcePasswordResetReason
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
||||
@@ -44,7 +45,7 @@ fun GetTokenResponseJson.Success.toUserState(
|
||||
kdfParallelism = this.kdfParallelism,
|
||||
userDecryptionOptions = this.userDecryptionOptions,
|
||||
),
|
||||
tokens = AccountJson.Tokens(
|
||||
tokens = AccountTokensJson(
|
||||
accessToken = accessToken,
|
||||
refreshToken = this.refreshToken,
|
||||
),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.x8bit.bitwarden.data.auth.repository.util
|
||||
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.AccountTokensJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.disk.model.UserStateJson
|
||||
import com.x8bit.bitwarden.data.auth.datasource.network.model.RefreshTokenResponseJson
|
||||
|
||||
@@ -27,7 +27,7 @@ fun RefreshTokenResponseJson.toUserStateJson(
|
||||
name = jwtTokenData.name,
|
||||
hasPremium = jwtTokenData.hasPremium,
|
||||
),
|
||||
tokens = AccountJson.Tokens(
|
||||
tokens = AccountTokensJson(
|
||||
accessToken = accessToken,
|
||||
refreshToken = this.refreshToken,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user