-
Notifications
You must be signed in to change notification settings - Fork 0
fix(#396): 캠페인 제안 상세 조회에 제품 이름 추가 #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| package com.example.RealMatch.business.application.service; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import com.example.RealMatch.brand.domain.entity.BrandAvailableSponsor; | ||
| import com.example.RealMatch.brand.domain.repository.BrandAvailableSponsorRepository; | ||
| import com.example.RealMatch.business.domain.entity.CampaignProposal; | ||
| import com.example.RealMatch.business.domain.repository.CampaignProposalRepository; | ||
| import com.example.RealMatch.business.exception.BusinessErrorCode; | ||
|
|
@@ -17,14 +21,22 @@ | |
| public class CampaignProposalQueryService { | ||
|
|
||
| private final CampaignProposalRepository campaignProposalRepository; | ||
| private final BrandAvailableSponsorRepository brandAvailableSponsorRepository; | ||
|
|
||
| public CampaignProposalDetailResponse getProposalDetail( | ||
| Long userId, | ||
| Long proposalId | ||
| ) { | ||
| CampaignProposal proposal = campaignProposalRepository.findByIdWithTags(proposalId) | ||
| .orElseThrow(() -> new CustomException(BusinessErrorCode.CAMPAIGN_PROPOSAL_NOT_FOUND)); | ||
|
|
||
| // TODO: 데모데이 이후에 해당 제품이 없으면 에러 던지는 방향으로 수정 필요!! + 조회 권한 로직 추가 필요(본인만 조회 가능) | ||
| String productName = Optional.ofNullable(proposal.getProductId()) | ||
| .flatMap(productId -> brandAvailableSponsorRepository | ||
| .findByBrandIdAndId(proposal.getBrand().getId(), productId)) | ||
| .map(BrandAvailableSponsor::getName) | ||
| .orElse(null); | ||
|
|
||
| return CampaignProposalDetailResponse.from(proposal); | ||
| return CampaignProposalDetailResponse.from(proposal, productName); | ||
|
Comment on lines
+33
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if (!proposal.getSenderUserId().equals(userId) && !proposal.getReceiverUserId().equals(userId)) {
throw new CustomException(BusinessErrorCode.CAMPAIGN_PROPOSAL_USER_MISMATCH);
}
String productName = Optional.ofNullable(proposal.getProductId())
.flatMap(productId -> brandAvailableSponsorRepository
.findByBrandIdAndId(proposal.getBrand().getId(), productId))
.map(BrandAvailableSponsor::getName)
.orElse(null);
return CampaignProposalDetailResponse.from(proposal, productName); |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
getProposalDetailmethod takes auserIdand aproposalIdbut fails to verify if the user is authorized to access the proposal. An attacker could potentially view any campaign proposal by providing its ID. The code even contains a TODO comment acknowledging the missing authorization check. Implement an authorization check to ensure theuserIdmatches either thesenderUserIdorreceiverUserIdof the proposal (or has appropriate administrative privileges).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추후 권한 확인 로직 추가 예정 (데모데이 이후)