Skip to content

Commit 52e3faf

Browse files
committed
♻️Refactor: @AuthenticationPrincipal 사용하여 보안 강화
1 parent 71e87ff commit 52e3faf

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/com/be/sportizebe/domain/user/controller/UserController.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.be.sportizebe.domain.user.dto.request.SignUpRequest;
44
import com.be.sportizebe.domain.user.dto.response.ProfileImageResponse;
55
import com.be.sportizebe.domain.user.dto.response.SignUpResponse;
6+
import com.be.sportizebe.domain.user.entity.User;
67
import com.be.sportizebe.domain.user.service.UserServiceImpl;
78
import com.be.sportizebe.global.response.BaseResponse;
89
import io.swagger.v3.oas.annotations.Operation;
@@ -12,6 +13,7 @@
1213
import org.springframework.http.HttpStatus;
1314
import org.springframework.http.MediaType;
1415
import org.springframework.http.ResponseEntity;
16+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1517
import org.springframework.web.bind.annotation.*;
1618
import org.springframework.web.multipart.MultipartFile;
1719

@@ -31,13 +33,13 @@ public ResponseEntity<BaseResponse<SignUpResponse>> signUp(@RequestBody @Valid S
3133
.body(BaseResponse.success("회원가입 성공", response));
3234
}
3335

34-
@PostMapping(value = "/{userId}/profile-image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
36+
@PostMapping(value = "/profile-image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
3537
@Operation(summary = "프로필 사진 업로드", description = "사용자 프로필 사진을 업로드합니다. (최대 5MB, jpg/jpeg/png/gif/webp 지원)")
3638
public ResponseEntity<BaseResponse<ProfileImageResponse>> uploadProfileImage(
37-
@PathVariable Long userId,
39+
@AuthenticationPrincipal User user,
3840
@RequestPart("file") MultipartFile file
3941
) {
40-
ProfileImageResponse response = userService.uploadProfileImage(userId, file);
42+
ProfileImageResponse response = userService.uploadProfileImage(user.getId(), file);
4143
return ResponseEntity.ok(BaseResponse.success("프로필 사진 업로드 성공", response));
4244
}
4345
}

0 commit comments

Comments
 (0)