비밀번호 확인부터

This commit is contained in:
kimdaae328 2025-02-27 12:41:31 +09:00
parent 476437f2e6
commit 9293bba077
3 changed files with 37 additions and 28 deletions

View File

@ -9,15 +9,16 @@
:comment="comment"
:showDetail="false"
:isLike="!isLike"
:isCommentPassword="comment.isCommentPassword"
:isCommentPassword="isCommentPassword"
:isCommentProfile="true"
@editClick="aaaa"
@deleteClick="$emit('deleteClick', comment)"
@updateReaction="handleUpdateReaction"
/>
<!-- <P>Commentpassssss: {{isCommentPassword}}</P> -->
<!-- :author="true" -->
<!-- 댓글 비밀번호 입력창 (익명일 경우) -->
<div v-if="isCommentPassword && unknown" class="mt-3 w-25 ms-auto">
<div v-if="isCommentPassword === comment.commentId && unknown" class="mt-3 w-25 ms-auto">
<div class="input-group">
<input
type="password"
@ -60,6 +61,7 @@
<!-- <p>대댓글 데이터(JSON): {{ JSON.stringify(child, null, 2) }}</p> -->
<!-- <p>comment child: {{ comment.children }}</p> -->
<!-- :unknown="child.author === '익명'" -->
<p>child.isCommentPassword: {{ child.isCommentPassword }}</p>
<BoardComment
:comment="child"
:unknown="child.author === '익명'"
@ -67,6 +69,7 @@
:isLike="true"
:isCommentProfile="true"
:isCommentAuthor="child.isCommentAuthor"
:isCommentPassword="isCommentPassword"
@editClick="$emit('editClick', $event)"
@deleteClick="$emit('deleteClick', child)"
@submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)"
@ -93,7 +96,7 @@ const props = defineProps({
},
unknown: {
type: Boolean,
default: true,
default: false,
},
isCommentAuthor: {
type: Boolean,

View File

@ -9,8 +9,8 @@
:unknown="unknown"
:comment="comment"
:isCommentAuthor="comment.isCommentAuthor"
:isCommentPassword="comment.isCommentPassword"
:isEditTextarea="comment.isEditTextarea"
:isCommentPassword="isCommentPassword"
:passwordCommentAlert="passwordCommentAlert"
@editClick="handleEditClick"
@deleteClick="handleDeleteClick"

View File

@ -170,7 +170,7 @@ const commentsWithAuthStatus = computed(() => {
isCommentAuthor: comment.authorId === currentUserId.value,
children: comment.children.map(reply => ({
...reply,
isCommentAuthor: reply.authorId === currentUserId.value
isCommentAuthor: reply.authorId === currentUserId.value,
}))
}));
// console.log(" commentsWithAuthStatus :", updatedComments);
@ -220,8 +220,8 @@ const fetchBoardDetails = async () => {
//
// profileName.value = '';
console.log("📌 게시글 작성자:", profileName.value); //
console.log("🔍 익명 여부 (unknown.value):", unknown.value); //
// console.log("📌 :", profileName.value); //
// console.log("🔍 (unknown.value):", unknown.value); //
authorId.value = data.authorId; // id
@ -382,7 +382,6 @@ const handleCommentSubmit = async (data, isCheck) => {
}
const { comment, password } = data;
const LOCBRDTYP = data.LOCBRDTYP || null;
if (!comment || comment.trim() === "") {
commentAlert.value = '댓글을 입력해주세요.';
@ -402,7 +401,7 @@ const handleCommentSubmit = async (data, isCheck) => {
LOCCMTRPY: comment,
LOCCMTPWD: isCheck ? password : '',
LOCCMTPNT: 1,
LOCBRDTYP
LOCBRDTYP: unknown.value ? "300102" : null
});
if (response.status === 200) {
@ -482,36 +481,36 @@ const findCommentById = (commentId, commentsList) => {
//
const editComment = (comment) => {
console.log('대댓글 수정 버튼 클릭')
//
const targetComment = findCommentById(comment.commentId, comments.value);
if (!targetComment) {
console.log("대댓글을 찾을 수 없음:", comment.commentId);
return;
}
// text ,
targetComment.isEditTextarea = !targetComment.isEditTextarea;
//
const isMyComment = comment.authorId === currentUserId.value;
const isAnonymous = comment.author === "익명";
//
if (unknown.value) {
console.log('익명 코멘트인가?')
if (isMyComment) {
//
targetComment.isEditTextarea = true;
} else if (isAnonymous) {
//
toggleCommentPassword(comment, "edit");
} else {
console.log("⛔ 다른 사용자 댓글 - 수정 불가");
}
}
//
const deleteComment = async (comment) => {
console.log('🗑 댓글 삭제 시도:', comment);
//
const isMyComment = comment.authorId === currentUserId.value;
if (unknown.value && !isMyComment) {
console.log('🛑 익명 사용자의 댓글 삭제 시도 (비밀번호 필요)');
if (comment.isEditTextarea) {
// ,
comment.isEditTextarea = false;
@ -521,26 +520,23 @@ const deleteComment = async (comment) => {
toggleCommentPassword(comment, "delete");
}
} else {
console.log('✅ 로그인 사용자 댓글 삭제 진행');
deleteReplyComment(comment);
}
};
//
const toggleCommentPassword = (comment, button) => {
if (lastCommentClickedButton.value === button && comment.isCommentPassword) {
comment.isCommentPassword = false;
if (lastCommentClickedButton.value === button && isCommentPassword.value === comment.commentId) {
isCommentPassword.value = false; //
} else {
//
comments.value.forEach(c => (c.isCommentPassword = false));
//
comment.isCommentPassword = true;
isCommentPassword.value = comment.commentId; //
}
lastCommentClickedButton.value = button;
};
const togglePassword = (button) => {
if (lastClickedButton.value === button) {
isPassword.value = !isPassword.value;
@ -597,16 +593,21 @@ const submitPassword = async () => {
// ( )
const submitCommentPassword = async (comment, password) => {
console.log("비밀번호 :", password);
console.log("댓글 ID:", comment.commentId);
if (!password) {
passwordCommentAlert.value = "비밀번호를 입력해주세요.";
return;
}
try {
console.log('서버로 비밀번호 확인 요청')
const response = await axios.post(`board/comment/${comment.commentId}/password`, {
LOCCMTPWD: password,
LOCCMTSEQ: comment.commentId,
});
console.log("✅ 서버 응답 데이터:", response.data);
if (response.data.code === 200 && response.data.data === true) {
passwordCommentAlert.value = "";
@ -624,9 +625,14 @@ const submitCommentPassword = async (comment, password) => {
}
lastCommentClickedButton.value = null;
} else {
console.log("❌ 비밀번호가 틀림");
passwordCommentAlert.value = "비밀번호가 일치하지 않습니다.";
}
} catch (error) {
console.log("🚨 서버 요청 중 오류 발생:", error.response?.data || error);
if (error.response?.status === 401) {
console.log("❌ 401 오류: 인증 실패 (비밀번호 불일치)");
}
passwordCommentAlert.value = "비밀번호가 일치하지 않습니다";
}
};