비밀번호 확인부터
This commit is contained in:
parent
476437f2e6
commit
9293bba077
@ -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,
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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 = "비밀번호가 일치하지 않습니다";
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user