Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,4 @@ public ResponseEntity<?> likePost(@PathVariable Long id,
return ResponseEntity.status(500).body("좋아요 처리에 실패했습니다.");
}
}

// 🔥 기존 데이터 업데이트를 위한 임시 엔드포인트 (관리자용)
@PostMapping("/update-counts")
@PreAuthorize("hasRole('ADMIN')")
public ResponseEntity<?> updateAllPostCounts(@AuthenticationPrincipal CustomUserDetails userDetails) {
// 관리자 권한 확인
if (!userDetails.getAuthorities().stream()
.anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN"))) {
return ResponseEntity.status(403).body("관리자 권한이 필요합니다.");
}
postService.updateAllPostCounts();
return ResponseEntity.ok(Map.of("message", "모든 게시글의 댓글 수와 좋아요 수가 업데이트되었습니다."));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/static/js/common/edit-qna.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async function checkPostOwnership() {
}

// 🔐 작성자 본인이 아니면 접근 차단
const isOwner = currentUser.username === post.userName;
const isOwner = currentUser.username === post.writer;
if (!isOwner) {
alert("본인이 작성한 게시글만 수정할 수 있습니다.");
window.location.replace(`/posts/detail?id=${postId}`);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/js/common/edit-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async function checkPostOwnership() {
}

// 🔐 작성자 본인이 아니면 접근 차단
const isOwner = currentUser.username === post.userName;
const isOwner = currentUser.username === post.writer;
if (!isOwner) {
alert("본인이 작성한 게시글만 수정할 수 있습니다.");
window.location.replace(`/posts/detail?id=${postId}`);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/js/common/edit-showoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async function checkPostOwnership() {
}

// 🔐 작성자 본인이 아니면 접근 차단
const isOwner = currentUser.username === post.userName;
const isOwner = currentUser.username === post.writer;
if (!isOwner) {
alert("본인이 작성한 게시글만 수정할 수 있습니다.");
window.location.replace(`/posts/detail?id=${postId}`);
Expand Down
9 changes: 2 additions & 7 deletions src/main/resources/templates/post-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,6 @@ <h1 class="post-title">게시글을 불러오는 중입니다... 🐾</h1>
</div>

<div class="post-content">
<div class="post-images">
<!-- 이미지가 AJAX로 로드됩니다 -->
<img src="/api/placeholder/400/320" alt="placeholder" class="loading-placeholder">
</div>

<p>게시글 내용을 불러오는 중입니다... 잠시만 기다려 주세요! 🐕‍🦺</p>

Expand Down Expand Up @@ -837,7 +833,7 @@ <h3>
const currentUser = await getCurrentUser();
const loggedIn = !!currentUser; // getCurrentUser 결과로 로그인 상태 판단

const isOwner = currentUser && (currentUser.username === post.userName);
const isOwner = currentUser && (currentUser.username === post.writer);
const container = document.getElementById("postDetail");

let petTypeLabel = '';
Expand Down Expand Up @@ -1159,8 +1155,7 @@ <h1 class="post-title">${post.title}</h1>
div.className = "comment";

// 🔐 댓글 작성자 본인인지 확인
const isCommentOwner = currentUser &&
(currentUser.username === comment.userName);
const isCommentOwner = currentUser && (currentUser.username === comment.writer);

// 🔐 댓글 작성자에게만 수정/삭제 버튼 표시
const commentActionsHtml = isCommentOwner ? `
Expand Down