Controller
💡@PreAuthorize
@PreAuthorize("#userId == authentication.principal.userId")
@PutMapping("/users/{userId}")
public void update(
@PathVariable Long userId,
@AuthenticationPrincipal CustomUserDetails user
) {
}
- userRole 역할 별로 필터링 하기
💡@AuthenticationPrincipal
@GetMapping("/profile")
public ResponseEntity<?> profile(
@AuthenticationPrincipal CustomUserDetails userDetails
) {
profileService.getProfile(userDetails.getUserId());
return ResponseEntity.ok().build();
}
- user 정보 받아오기
'Projects > HubEleven' 카테고리의 다른 글
| [리팩토링] 공통 모듈 수정으로 인한 리팩토링 (0) | 2026.01.15 |
|---|---|
| [리팩토링] 권한 별 기능 제한 로직 구현 (2) (업데이트 중..) (0) | 2026.01.08 |
| [리팩토링] 권한 별 기능 제한 로직 구현 (1) (업데이트 중..) (0) | 2026.01.07 |
| [리팩토링] Swagger Request DTO 메서드 충돌 트러블슈팅 (0) | 2026.01.06 |
| [동시성 처리] 테스트 코드 런타임 에러 발생 (업데이트 중..) (0) | 2026.01.05 |