KotlinAuthorizationDifficulty 2/3
// UserController.kt
@PutMapping("/api/users/me")
fun updateProfile(
@AuthenticationPrincipal user: AppUser,
@RequestBody body: UserEntity,
): UserEntity {
body.id = user.id
return userRepository.save(body)
}
// UserEntity.kt
@Entity
data class UserEntity(
@Id var id: Long = 0,
var email: String = "",
var displayName: String = "",
var role: String = "USER",
var passwordHash: String = "",
)