Update status code for ApiError.InvalidCredentialError

This commit is contained in:
Hubert Van De Walle 2020-04-12 16:58:29 +02:00
parent 5d93b8054e
commit 3d1722fc62

View File

@ -36,11 +36,11 @@ class UserController(kodein: Kodein) : KodeinController(kodein) {
.where { Users.username eq credential.username }
.map { row -> row[Users.email]!! to row[Users.password]!! }
.firstOrNull()
?: return@post call.respond(HttpStatusCode.BadRequest, ApiError.InvalidCredentialError)
?: return@post call.respond(HttpStatusCode.Unauthorized, ApiError.InvalidCredentialError)
if (!BCrypt.checkpw(credential.password, password)) {
return@post call.respond(HttpStatusCode.BadRequest, ApiError.InvalidCredentialError)
return@post call.respond(HttpStatusCode.Unauthorized, ApiError.InvalidCredentialError)
}
return@post call.respond(Response(simpleJwt.sign(email)))