import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.html.*
+import org.litote.kmongo.eq
import starshipfights.CurrentConfiguration
import starshipfights.data.Id
import starshipfights.data.admiralty.Admiral
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 {
- User(username = credentials.name).also {
+ 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)
}
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
}
override suspend fun locate(bson: Bson): T? {
- return collection().findOne(bson)
+ try {
+ return collection().findOne(bson)
+ } catch (ex: Exception) {
+ sfLogger.error("Got exception from table ${kclass.simpleName}", ex)
+ throw ex
+ }
}
override suspend fun update(where: Bson, set: Bson) {