mirror of
https://github.com/2martens/tsw-timetable.git
synced 2026-10-19 16:56:51 +02:00
fix: Extract token before usage
This commit is contained in:
@@ -16,7 +16,7 @@ import org.springframework.http.HttpStatus
|
|||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.security.authorization.AuthorizationDeniedException
|
import org.springframework.security.authorization.AuthorizationDeniedException
|
||||||
import org.springframework.security.core.context.SecurityContextHolder
|
import org.springframework.security.core.context.SecurityContextHolder
|
||||||
import org.springframework.security.oauth2.jwt.Jwt
|
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -64,8 +64,8 @@ class UserController(
|
|||||||
]) body: User
|
]) body: User
|
||||||
): ResponseEntity<User> {
|
): ResponseEntity<User> {
|
||||||
val authentication = SecurityContextHolder.getContext().authentication
|
val authentication = SecurityContextHolder.getContext().authentication
|
||||||
val jwt = authentication as Jwt
|
val jwt = authentication as JwtAuthenticationToken
|
||||||
val authorizedParty = jwt.getClaimAsString("azp")
|
val authorizedParty = jwt.token.getClaimAsString("azp")
|
||||||
var created = false
|
var created = false
|
||||||
|
|
||||||
val userIdConverted = UserId.of(NonEmptyString(userId))
|
val userIdConverted = UserId.of(NonEmptyString(userId))
|
||||||
|
|||||||
Reference in New Issue
Block a user