From d6cb316e1c886761cce70a9a04c09c2614656b3a Mon Sep 17 00:00:00 2001 From: TheSaminator Date: Sun, 6 Feb 2022 18:57:30 -0500 Subject: [PATCH] give up --- .../kotlin/starshipfights/auth/providers.kt | 4 ---- .../kotlin/starshipfights/data/data_documents.kt | 16 ++-------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/jvmMain/kotlin/starshipfights/auth/providers.kt b/src/jvmMain/kotlin/starshipfights/auth/providers.kt index abd3eb7..f76dd3d 100644 --- a/src/jvmMain/kotlin/starshipfights/auth/providers.kt +++ b/src/jvmMain/kotlin/starshipfights/auth/providers.kt @@ -25,7 +25,6 @@ import starshipfights.game.AdmiralRank import starshipfights.game.Faction import starshipfights.info.* import starshipfights.redirect -import starshipfights.sfLogger interface AuthProvider { fun installAuth(conf: Authentication.Configuration) @@ -195,13 +194,10 @@ object TestAuthProvider : AuthProvider { val originAddress = request.origin.remoteHost val userAgent = request.userAgent() if (userAgent != null && credentials.name.isValidUsername() && credentials.password == TEST_PASSWORD) { - sfLogger.info("Attempting to find user ${credentials.name}") val user = User.locate(User::username eq credentials.name) ?: User(username = credentials.name).also { - sfLogger.info("Attempting to add user with name ${credentials.name}") User.put(it) } - sfLogger.info("Got user ${user.id}") UserSession( user = user.id, diff --git a/src/jvmMain/kotlin/starshipfights/data/data_documents.kt b/src/jvmMain/kotlin/starshipfights/data/data_documents.kt index 13f0de0..3cd0c44 100644 --- a/src/jvmMain/kotlin/starshipfights/data/data_documents.kt +++ b/src/jvmMain/kotlin/starshipfights/data/data_documents.kt @@ -5,12 +5,10 @@ import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow import kotlinx.serialization.SerialName import org.bson.conversions.Bson -import org.litote.kmongo.coroutine.CoroutineCollection import org.litote.kmongo.coroutine.coroutine import org.litote.kmongo.serialization.IdController import org.slf4j.Logger import org.slf4j.LoggerFactory -import starshipfights.sfLogger import kotlin.coroutines.CoroutineContext import kotlin.reflect.KClass import kotlin.reflect.KProperty1 @@ -72,12 +70,7 @@ interface DocumentTable> { } private class DocumentTableImpl>(val kclass: KClass, private val initFunc: (DocumentTable) -> Unit) : DocumentTable { - private var collection: CoroutineCollection? = null - suspend fun collection() = - collection - ?: ConnectionHolder.getDatabase().database.getCollection(kclass.simpleName, kclass.java).coroutine.also { - collection = it - } + suspend fun collection() = ConnectionHolder.getDatabase().database.getCollection(kclass.simpleName, kclass.java).coroutine override fun initialize() { initFunc(this) @@ -112,12 +105,7 @@ private class DocumentTableImpl>(val kclass: KClass, priv } override suspend fun locate(bson: Bson): T? { - try { - return collection().findOne(bson) - } catch (ex: Exception) { - sfLogger.error("Got exception from table ${kclass.simpleName}", ex) - throw ex - } + return collection().findOne(bson) } override suspend fun update(where: Bson, set: Bson) { -- 2.25.1