one more try to fix nosuchelement exception
This commit is contained in:
features
auth
client
src
commonMain
kotlin
dev
inmo
postssystem
features
auth
client
jsMain
kotlin
dev
inmo
postssystem
features
auth
client
common
src
commonMain
kotlin
dev
inmo
postssystem
features
auth
common
common
client
src
commonMain
kotlin
dev
inmo
postssystem
features
common
common
ui
roles
common
src
commonMain
kotlin
dev
inmo
postssystem
features
roles
common
manager
common
src
commonMain
kotlin
dev
inmo
postssystem
features
roles
manager
common
server
src
jvmMain
kotlin
dev
inmo
postssystem
features
roles
gradle
targets/telegram/loader/server/src/jvmMain/kotlin/dev/inmo/postssystem/targets/telegram/loader/server
29
features/auth/common/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/common/AuthModels.kt
29
features/auth/common/src/commonMain/kotlin/dev/inmo/postssystem/features/auth/common/AuthModels.kt
@ -8,7 +8,6 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable(AuthKeySerializer::class)
|
||||
sealed interface AuthKey
|
||||
|
||||
@Serializable
|
||||
@ -18,34 +17,6 @@ private data class AuthKeySurrogate(
|
||||
val refreshToken: RefreshToken?
|
||||
)
|
||||
|
||||
@Serializer(AuthKey::class)
|
||||
object AuthKeySerializer : KSerializer<AuthKey> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = AuthKeySurrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): AuthKey {
|
||||
val surrogate = AuthKeySurrogate.serializer().deserialize(decoder)
|
||||
when {
|
||||
surrogate.authCreds != null -> return surrogate.authCreds
|
||||
surrogate.token != null -> return surrogate.token
|
||||
surrogate.refreshToken != null -> return surrogate.refreshToken
|
||||
}
|
||||
error("Unsupported version of auth key surrogate")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: AuthKey) {
|
||||
AuthKeySurrogate.serializer().serialize(
|
||||
encoder,
|
||||
AuthKeySurrogate(
|
||||
value as? AuthCreds,
|
||||
value as? AuthToken,
|
||||
value as? RefreshToken
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("authcreds")
|
||||
data class AuthCreds(
|
||||
|
Reference in New Issue
Block a user