Skip to content

Commit

Permalink
refactor: (#1) Using Non-Label Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Mar 30, 2023
1 parent c1724f5 commit 3313a9b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/kotlin/com/dsm/plugins/Security.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ fun Application.configureSecurity() {
.build()
)

validate valid@{ credential ->
val id: UUID = credential.payload.getClaim(JwtGenerator.JWT_STUDENT_ID).asString()
?.let(UUID::fromString) ?: return@valid null

if (!studentRepository.existsById(id)) return@valid null

JWTPrincipal(credential.payload)
validate { credential ->
credential.payload.getClaim(JwtGenerator.JWT_STUDENT_ID).asString()?.let {
if (studentRepository.existsById(it.let(UUID::fromString))) null
else JWTPrincipal(credential.payload)
}
}

challenge { _, _ ->
Expand Down

0 comments on commit 3313a9b

Please sign in to comment.