From 96c54d26fd0439e23ba1414eab9a2cc47046fd02 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 1 May 2023 10:48:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=91=E3=82=B9=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=80=81=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E5=90=8D?= =?UTF-8?q?=E3=81=8C=E9=96=93=E9=81=95=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=AB=E6=AD=A3=E5=B8=B8=E3=81=AAHTTP=20St?= =?UTF-8?q?atus=20Code=E3=82=92=E8=BF=94=E3=81=99=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 4 ++++ .../usbharu/hideout/exception/UserNotFoundException.kt | 10 ++-------- .../kotlin/dev/usbharu/hideout/plugins/StatusPages.kt | 6 +++--- .../usbharu/hideout/service/impl/UserAuthService.kt | 3 +-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b7cca720..e28896a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,6 +41,10 @@ tasks.withType { } } +tasks.clean { + delete += listOf("$rootDir/src/main/resources/static") +} + repositories { mavenCentral() } diff --git a/src/main/kotlin/dev/usbharu/hideout/exception/UserNotFoundException.kt b/src/main/kotlin/dev/usbharu/hideout/exception/UserNotFoundException.kt index 4634e141..0c8ca15e 100644 --- a/src/main/kotlin/dev/usbharu/hideout/exception/UserNotFoundException.kt +++ b/src/main/kotlin/dev/usbharu/hideout/exception/UserNotFoundException.kt @@ -1,14 +1,8 @@ package dev.usbharu.hideout.exception -class UserNotFoundException : Exception { +class UserNotFoundException : IllegalArgumentException { constructor() : super() - constructor(message: String?) : super(message) + constructor(s: String?) : super(s) constructor(message: String?, cause: Throwable?) : super(message, cause) constructor(cause: Throwable?) : super(cause) - constructor( - message: String?, - cause: Throwable?, - enableSuppression: Boolean, - writableStackTrace: Boolean - ) : super(message, cause, enableSuppression, writableStackTrace) } diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt index cd078e28..67ffdb1b 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/StatusPages.kt @@ -7,11 +7,11 @@ import io.ktor.server.response.* fun Application.configureStatusPages() { install(StatusPages) { - exception { call, cause -> - call.respondText(text = "500: $cause", status = HttpStatusCode.InternalServerError) - } exception { call, cause -> call.respondText(text = "400: $cause", status = HttpStatusCode.BadRequest) } + exception { call, cause -> + call.respondText(text = "500: $cause", status = HttpStatusCode.InternalServerError) + } } } diff --git a/src/main/kotlin/dev/usbharu/hideout/service/impl/UserAuthService.kt b/src/main/kotlin/dev/usbharu/hideout/service/impl/UserAuthService.kt index 2d1ef29b..51356cff 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/impl/UserAuthService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/impl/UserAuthService.kt @@ -1,7 +1,6 @@ package dev.usbharu.hideout.service.impl import dev.usbharu.hideout.config.Config -import dev.usbharu.hideout.exception.UserNotFoundException import dev.usbharu.hideout.repository.IUserRepository import dev.usbharu.hideout.service.IUserAuthService import io.ktor.util.* @@ -24,7 +23,7 @@ class UserAuthService( override suspend fun verifyAccount(username: String, password: String): Boolean { val userEntity = userRepository.findByNameAndDomain(username, Config.configData.domain) - ?: throw UserNotFoundException("$username was not found") + ?: return false return userEntity.password == hash(password) }