Skip to content

Commit

Permalink
fix: spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
powercasgamer committed Nov 12, 2023
1 parent 58786b7 commit c612cb1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
4 changes: 0 additions & 4 deletions app/src/main/kotlin/dev/mizule/imagery/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.benmanes.caffeine.cache.Cache
import com.github.benmanes.caffeine.cache.Caffeine
import dev.mizule.imagery.app.auth.AuthHandler
import dev.mizule.imagery.app.auth.UserConfig
import dev.mizule.imagery.app.config.Config
import dev.mizule.imagery.app.model.ImageLookupResult
import dev.mizule.imagery.app.model.Roles
Expand Down Expand Up @@ -100,9 +99,7 @@ class App(private val config: Config, usersConfigOption: String) {
throw io.javalin.http.ForbiddenResponse()
} else {
logger.info { "Token: $token Authorized" }

}

}
}
javalin.post("/upload", ::handleFileUpload, Roles.PRIVATE)
Expand All @@ -123,7 +120,6 @@ class App(private val config: Config, usersConfigOption: String) {
}
val token = ctx.header("Authorization") ?: throw io.javalin.http.ForbiddenResponse()


val uploadedFile = UploadedFile(
id,
authHandler.getUserByToken(token)?.username ?: "Unknown",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.spongepowered.configurate.kotlin.extensions.get
import org.spongepowered.configurate.kotlin.objectMapperFactory
import java.security.SecureRandom
import java.util.Base64
import java.util.HashMap
import kotlin.io.path.Path
import kotlin.io.path.exists

Expand Down Expand Up @@ -46,7 +45,7 @@ class AuthHandler(userConfigPath: String) {
fun createUser(name: String): User {
val secret = ByteArray(48)
SecureRandom().nextBytes(secret)
return createUser(name, Base64.getEncoder().encodeToString(secret));
return createUser(name, Base64.getEncoder().encodeToString(secret))
}

fun isAuthorized(token: String): Boolean {
Expand All @@ -65,4 +64,4 @@ class AuthHandler(userConfigPath: String) {
usersLoader.save(usersNode)
return user
}
}
}
5 changes: 2 additions & 3 deletions app/src/main/kotlin/dev/mizule/imagery/app/auth/UserConfig.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package dev.mizule.imagery.app.auth

import org.spongepowered.configurate.objectmapping.ConfigSerializable
import org.spongepowered.configurate.objectmapping.meta.Comment

@ConfigSerializable
data class UserConfig(

val users: MutableList<User> = mutableListOf()
)
val users: MutableList<User> = mutableListOf(),
)
3 changes: 1 addition & 2 deletions app/src/main/kotlin/dev/mizule/imagery/app/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package dev.mizule.imagery.app.config

import dev.mizule.imagery.app.App
import org.spongepowered.configurate.objectmapping.ConfigSerializable
import org.spongepowered.configurate.objectmapping.meta.Comment

Expand All @@ -41,4 +40,4 @@ data class Config(

@Comment("The path to the uploaded file storage directory.")
val storagePath: String = "./storage",
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
package dev.mizule.imagery.app.launcher

import dev.mizule.imagery.app.App
import dev.mizule.imagery.app.auth.UserConfig
import dev.mizule.imagery.app.config.Config
import kotlinx.cli.ArgParser
import kotlinx.cli.ArgType
import kotlinx.cli.default
import org.spongepowered.configurate.hocon.HoconConfigurationLoader
import org.spongepowered.configurate.jackson.JacksonConfigurationLoader
import org.spongepowered.configurate.kotlin.extensions.get
import org.spongepowered.configurate.kotlin.objectMapperFactory
import kotlin.io.path.Path
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/dev/mizule/imagery/app/model/Roles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import io.javalin.security.RouteRole
enum class Roles : RouteRole {

PUBLIC,
PRIVATE
}
PRIVATE,
}

0 comments on commit c612cb1

Please sign in to comment.