Remove useless try catch

This commit is contained in:
Hubert Van De Walle 2020-09-29 18:04:11 +02:00
parent 23eb5ff433
commit 16faac962b

View File

@ -6,7 +6,6 @@ import be.simplenotes.extensions.notFound
import be.simplenotes.extensions.ok
import be.simplenotes.repositories.UserRepository
import be.simplenotes.security.SimpleJwt
import com.auth0.jwt.exceptions.JWTVerificationException
import org.http4k.core.Body
import org.http4k.core.Method.*
import org.http4k.core.Response
@ -60,13 +59,7 @@ class UserRoutes(private val userRepository: UserRepository, private val simpleJ
},
"/whoami" bind GET to {
jwtLens(it)?.value
?.let { token ->
try {
simpleJwt.extract(token)
} catch (e: JWTVerificationException) {
null
}
}
?.let { token -> simpleJwt.extract(token) }
?.let { id -> Response.ok().with(userLens of userRepository.find(id)!!) }
?: Response.notFound()
}