비밀번호 확인부터
This commit is contained in:
parent
476437f2e6
commit
9293bba077
@ -9,15 +9,16 @@
|
|||||||
:comment="comment"
|
:comment="comment"
|
||||||
:showDetail="false"
|
:showDetail="false"
|
||||||
:isLike="!isLike"
|
:isLike="!isLike"
|
||||||
:isCommentPassword="comment.isCommentPassword"
|
:isCommentPassword="isCommentPassword"
|
||||||
:isCommentProfile="true"
|
:isCommentProfile="true"
|
||||||
@editClick="aaaa"
|
@editClick="aaaa"
|
||||||
@deleteClick="$emit('deleteClick', comment)"
|
@deleteClick="$emit('deleteClick', comment)"
|
||||||
@updateReaction="handleUpdateReaction"
|
@updateReaction="handleUpdateReaction"
|
||||||
/>
|
/>
|
||||||
|
<!-- <P>Commentpassssss: {{isCommentPassword}}</P> -->
|
||||||
<!-- :author="true" -->
|
<!-- :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">
|
<div class="input-group">
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
@ -60,6 +61,7 @@
|
|||||||
<!-- <p>대댓글 데이터(JSON): {{ JSON.stringify(child, null, 2) }}</p> -->
|
<!-- <p>대댓글 데이터(JSON): {{ JSON.stringify(child, null, 2) }}</p> -->
|
||||||
<!-- <p>comment child: {{ comment.children }}</p> -->
|
<!-- <p>comment child: {{ comment.children }}</p> -->
|
||||||
<!-- :unknown="child.author === '익명'" -->
|
<!-- :unknown="child.author === '익명'" -->
|
||||||
|
<p>child.isCommentPassword: {{ child.isCommentPassword }}</p>
|
||||||
<BoardComment
|
<BoardComment
|
||||||
:comment="child"
|
:comment="child"
|
||||||
:unknown="child.author === '익명'"
|
:unknown="child.author === '익명'"
|
||||||
@ -67,6 +69,7 @@
|
|||||||
:isLike="true"
|
:isLike="true"
|
||||||
:isCommentProfile="true"
|
:isCommentProfile="true"
|
||||||
:isCommentAuthor="child.isCommentAuthor"
|
:isCommentAuthor="child.isCommentAuthor"
|
||||||
|
:isCommentPassword="isCommentPassword"
|
||||||
@editClick="$emit('editClick', $event)"
|
@editClick="$emit('editClick', $event)"
|
||||||
@deleteClick="$emit('deleteClick', child)"
|
@deleteClick="$emit('deleteClick', child)"
|
||||||
@submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)"
|
@submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)"
|
||||||
@ -93,7 +96,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
unknown: {
|
unknown: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: false,
|
||||||
},
|
},
|
||||||
isCommentAuthor: {
|
isCommentAuthor: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
:unknown="unknown"
|
:unknown="unknown"
|
||||||
:comment="comment"
|
:comment="comment"
|
||||||
:isCommentAuthor="comment.isCommentAuthor"
|
:isCommentAuthor="comment.isCommentAuthor"
|
||||||
:isCommentPassword="comment.isCommentPassword"
|
|
||||||
:isEditTextarea="comment.isEditTextarea"
|
:isEditTextarea="comment.isEditTextarea"
|
||||||
|
:isCommentPassword="isCommentPassword"
|
||||||
:passwordCommentAlert="passwordCommentAlert"
|
:passwordCommentAlert="passwordCommentAlert"
|
||||||
@editClick="handleEditClick"
|
@editClick="handleEditClick"
|
||||||
@deleteClick="handleDeleteClick"
|
@deleteClick="handleDeleteClick"
|
||||||
|
|||||||
@ -170,7 +170,7 @@ const commentsWithAuthStatus = computed(() => {
|
|||||||
isCommentAuthor: comment.authorId === currentUserId.value,
|
isCommentAuthor: comment.authorId === currentUserId.value,
|
||||||
children: comment.children.map(reply => ({
|
children: comment.children.map(reply => ({
|
||||||
...reply,
|
...reply,
|
||||||
isCommentAuthor: reply.authorId === currentUserId.value
|
isCommentAuthor: reply.authorId === currentUserId.value,
|
||||||
}))
|
}))
|
||||||
}));
|
}));
|
||||||
// console.log("✅ commentsWithAuthStatus 업데이트됨:", updatedComments);
|
// console.log("✅ commentsWithAuthStatus 업데이트됨:", updatedComments);
|
||||||
@ -220,8 +220,8 @@ const fetchBoardDetails = async () => {
|
|||||||
// 익명확인하고 싶을때
|
// 익명확인하고 싶을때
|
||||||
// profileName.value = '익명';
|
// profileName.value = '익명';
|
||||||
|
|
||||||
console.log("📌 게시글 작성자:", profileName.value); // 작성자 이름 출력
|
// console.log("📌 게시글 작성자:", profileName.value); // 작성자 이름 출력
|
||||||
console.log("🔍 익명 여부 (unknown.value):", unknown.value); // 익명 여부 확인
|
// console.log("🔍 익명 여부 (unknown.value):", unknown.value); // 익명 여부 확인
|
||||||
|
|
||||||
|
|
||||||
authorId.value = data.authorId; //게시글 작성자 id
|
authorId.value = data.authorId; //게시글 작성자 id
|
||||||
@ -382,7 +382,6 @@ const handleCommentSubmit = async (data, isCheck) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { comment, password } = data;
|
const { comment, password } = data;
|
||||||
const LOCBRDTYP = data.LOCBRDTYP || null;
|
|
||||||
|
|
||||||
if (!comment || comment.trim() === "") {
|
if (!comment || comment.trim() === "") {
|
||||||
commentAlert.value = '댓글을 입력해주세요.';
|
commentAlert.value = '댓글을 입력해주세요.';
|
||||||
@ -402,7 +401,7 @@ const handleCommentSubmit = async (data, isCheck) => {
|
|||||||
LOCCMTRPY: comment,
|
LOCCMTRPY: comment,
|
||||||
LOCCMTPWD: isCheck ? password : '',
|
LOCCMTPWD: isCheck ? password : '',
|
||||||
LOCCMTPNT: 1,
|
LOCCMTPNT: 1,
|
||||||
LOCBRDTYP
|
LOCBRDTYP: unknown.value ? "300102" : null
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
@ -482,36 +481,36 @@ const findCommentById = (commentId, commentsList) => {
|
|||||||
|
|
||||||
// 댓글 수정 버튼 클릭
|
// 댓글 수정 버튼 클릭
|
||||||
const editComment = (comment) => {
|
const editComment = (comment) => {
|
||||||
console.log('대댓글 수정 버튼 클릭')
|
|
||||||
|
|
||||||
// 부모 또는 대댓글을 찾아서 가져오기
|
// 부모 또는 대댓글을 찾아서 가져오기
|
||||||
const targetComment = findCommentById(comment.commentId, comments.value);
|
const targetComment = findCommentById(comment.commentId, comments.value);
|
||||||
|
|
||||||
if (!targetComment) {
|
if (!targetComment) {
|
||||||
console.log("대댓글을 찾을 수 없음:", comment.commentId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 수정 text창 열림, 닫힘 유무 토글
|
// 댓글 작성자가 현재 로그인한 사용자와 동일한지 확인
|
||||||
targetComment.isEditTextarea = !targetComment.isEditTextarea;
|
const isMyComment = comment.authorId === currentUserId.value;
|
||||||
|
const isAnonymous = comment.author === "익명";
|
||||||
|
|
||||||
// 익명일 경우 비밀번호 입력창 활성화
|
if (isMyComment) {
|
||||||
if (unknown.value) {
|
// 본인 댓글이면 바로 수정 모드 활성화
|
||||||
console.log('익명 코멘트인가?')
|
targetComment.isEditTextarea = true;
|
||||||
|
} else if (isAnonymous) {
|
||||||
|
// 익명 댓글이면 비밀번호 입력창 띄우기
|
||||||
toggleCommentPassword(comment, "edit");
|
toggleCommentPassword(comment, "edit");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("⛔ 다른 사용자 댓글 - 수정 불가");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 댓글 삭제 버튼 클릭
|
// 댓글 삭제 버튼 클릭
|
||||||
const deleteComment = async (comment) => {
|
const deleteComment = async (comment) => {
|
||||||
console.log('🗑 댓글 삭제 시도:', comment);
|
|
||||||
|
|
||||||
// 익명 사용자인 경우
|
// 익명 사용자인 경우
|
||||||
const isMyComment = comment.authorId === currentUserId.value;
|
const isMyComment = comment.authorId === currentUserId.value;
|
||||||
|
|
||||||
if (unknown.value && !isMyComment) {
|
if (unknown.value && !isMyComment) {
|
||||||
console.log('🛑 익명 사용자의 댓글 삭제 시도 (비밀번호 필요)');
|
|
||||||
|
|
||||||
if (comment.isEditTextarea) {
|
if (comment.isEditTextarea) {
|
||||||
// 현재 수정 중이라면 수정 모드를 끄고, 삭제 비밀번호 입력창을 띄움
|
// 현재 수정 중이라면 수정 모드를 끄고, 삭제 비밀번호 입력창을 띄움
|
||||||
comment.isEditTextarea = false;
|
comment.isEditTextarea = false;
|
||||||
@ -521,26 +520,23 @@ const deleteComment = async (comment) => {
|
|||||||
toggleCommentPassword(comment, "delete");
|
toggleCommentPassword(comment, "delete");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('✅ 로그인 사용자 댓글 삭제 진행');
|
|
||||||
deleteReplyComment(comment);
|
deleteReplyComment(comment);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 익명 비밀번호 창 토글
|
// 익명 비밀번호 창 토글
|
||||||
const toggleCommentPassword = (comment, button) => {
|
const toggleCommentPassword = (comment, button) => {
|
||||||
if (lastCommentClickedButton.value === button && comment.isCommentPassword) {
|
if (lastCommentClickedButton.value === button && isCommentPassword.value === comment.commentId) {
|
||||||
comment.isCommentPassword = false;
|
isCommentPassword.value = false; // 비밀번호 창 닫기
|
||||||
} else {
|
} else {
|
||||||
// 모든 댓글의 비밀번호 입력창 닫기
|
isCommentPassword.value = comment.commentId; // 비밀번호 창 열기
|
||||||
comments.value.forEach(c => (c.isCommentPassword = false));
|
|
||||||
|
|
||||||
// 현재 선택된 댓글만 비밀번호 입력창 열기
|
|
||||||
comment.isCommentPassword = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastCommentClickedButton.value = button;
|
lastCommentClickedButton.value = button;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const togglePassword = (button) => {
|
const togglePassword = (button) => {
|
||||||
if (lastClickedButton.value === button) {
|
if (lastClickedButton.value === button) {
|
||||||
isPassword.value = !isPassword.value;
|
isPassword.value = !isPassword.value;
|
||||||
@ -597,16 +593,21 @@ const submitPassword = async () => {
|
|||||||
// 댓글 삭제 (비밀번호 확인 후)
|
// 댓글 삭제 (비밀번호 확인 후)
|
||||||
const submitCommentPassword = async (comment, password) => {
|
const submitCommentPassword = async (comment, password) => {
|
||||||
|
|
||||||
|
console.log("비밀번호 :", password);
|
||||||
|
console.log("댓글 ID:", comment.commentId);
|
||||||
|
|
||||||
if (!password) {
|
if (!password) {
|
||||||
passwordCommentAlert.value = "비밀번호를 입력해주세요.";
|
passwordCommentAlert.value = "비밀번호를 입력해주세요.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log('서버로 비밀번호 확인 요청')
|
||||||
const response = await axios.post(`board/comment/${comment.commentId}/password`, {
|
const response = await axios.post(`board/comment/${comment.commentId}/password`, {
|
||||||
LOCCMTPWD: password,
|
LOCCMTPWD: password,
|
||||||
LOCCMTSEQ: comment.commentId,
|
LOCCMTSEQ: comment.commentId,
|
||||||
});
|
});
|
||||||
|
console.log("✅ 서버 응답 데이터:", response.data);
|
||||||
|
|
||||||
if (response.data.code === 200 && response.data.data === true) {
|
if (response.data.code === 200 && response.data.data === true) {
|
||||||
passwordCommentAlert.value = "";
|
passwordCommentAlert.value = "";
|
||||||
@ -624,9 +625,14 @@ const submitCommentPassword = async (comment, password) => {
|
|||||||
}
|
}
|
||||||
lastCommentClickedButton.value = null;
|
lastCommentClickedButton.value = null;
|
||||||
} else {
|
} else {
|
||||||
|
console.log("❌ 비밀번호가 틀림");
|
||||||
passwordCommentAlert.value = "비밀번호가 일치하지 않습니다.";
|
passwordCommentAlert.value = "비밀번호가 일치하지 않습니다.";
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("🚨 서버 요청 중 오류 발생:", error.response?.data || error);
|
||||||
|
if (error.response?.status === 401) {
|
||||||
|
console.log("❌ 401 오류: 인증 실패 (비밀번호 불일치)");
|
||||||
|
}
|
||||||
passwordCommentAlert.value = "비밀번호가 일치하지 않습니다";
|
passwordCommentAlert.value = "비밀번호가 일치하지 않습니다";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user