Remove useless try catch
This commit is contained in:
parent
23eb5ff433
commit
16faac962b
@ -6,7 +6,6 @@ import be.simplenotes.extensions.notFound
|
|||||||
import be.simplenotes.extensions.ok
|
import be.simplenotes.extensions.ok
|
||||||
import be.simplenotes.repositories.UserRepository
|
import be.simplenotes.repositories.UserRepository
|
||||||
import be.simplenotes.security.SimpleJwt
|
import be.simplenotes.security.SimpleJwt
|
||||||
import com.auth0.jwt.exceptions.JWTVerificationException
|
|
||||||
import org.http4k.core.Body
|
import org.http4k.core.Body
|
||||||
import org.http4k.core.Method.*
|
import org.http4k.core.Method.*
|
||||||
import org.http4k.core.Response
|
import org.http4k.core.Response
|
||||||
@ -60,13 +59,7 @@ class UserRoutes(private val userRepository: UserRepository, private val simpleJ
|
|||||||
},
|
},
|
||||||
"/whoami" bind GET to {
|
"/whoami" bind GET to {
|
||||||
jwtLens(it)?.value
|
jwtLens(it)?.value
|
||||||
?.let { token ->
|
?.let { token -> simpleJwt.extract(token) }
|
||||||
try {
|
|
||||||
simpleJwt.extract(token)
|
|
||||||
} catch (e: JWTVerificationException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?.let { id -> Response.ok().with(userLens of userRepository.find(id)!!) }
|
?.let { id -> Response.ok().with(userLens of userRepository.find(id)!!) }
|
||||||
?: Response.notFound()
|
?: Response.notFound()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user