give up
authorTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 6 Feb 2022 23:57:30 +0000 (18:57 -0500)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Sun, 6 Feb 2022 23:57:30 +0000 (18:57 -0500)
src/jvmMain/kotlin/starshipfights/auth/providers.kt
src/jvmMain/kotlin/starshipfights/data/data_documents.kt

index abd3eb7aff285e376fca25b461ab48eca94f75cb..f76dd3dec8ffb5cfcbb899ef1bad5710292f8b69 100644 (file)
@@ -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,
index 13f0de03f1de445ec173fba31b0a5f062ea83482..3cd0c44ad1c116b92e0723a6df8ef118e9f11643 100644 (file)
@@ -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<T : DataDocument<T>> {
 }
 
 private class DocumentTableImpl<T : DataDocument<T>>(val kclass: KClass<T>, private val initFunc: (DocumentTable<T>) -> Unit) : DocumentTable<T> {
-       private var collection: CoroutineCollection<T>? = 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<T : DataDocument<T>>(val kclass: KClass<T>, 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) {