feat: [users] 사용자 등록 시 비밀번호 자동 생성 및 이메일 발송

- 사용자 등록 시 비밀번호 입력 필드 제거
- 임의 비밀번호 자동 생성 후 이메일 발송
- 사용자 수정 페이지에 비밀번호 초기화 버튼 추가
- 사용자 모달에 비밀번호 초기화 버튼 추가
- 사용자 모달 프로필 이미지 없을 때 이름 첫글자 표시 (한글 지원)
- UserPasswordMail 클래스 및 이메일 템플릿 추가
This commit is contained in:
2025-12-01 10:50:16 +09:00
parent 4a454db0dc
commit 85cbe23782
10 changed files with 355 additions and 44 deletions

View File

@@ -182,6 +182,39 @@ const UserModal = {
alert('복원에 실패했습니다.');
}
}
},
// 비밀번호 초기화 실행
async resetPassword() {
if (!this.currentUserId) return;
const userName = document.getElementById('user-modal-name')?.textContent || '이 사용자';
if (!confirm(`"${userName}"의 비밀번호를 초기화하시겠습니까?\n\n임시 비밀번호가 생성되어 사용자 이메일로 발송됩니다.`)) {
return;
}
try {
const response = await fetch(`/api/admin/users/${this.currentUserId}/reset-password`, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (data.success) {
alert(data.message || '비밀번호가 초기화되었습니다.');
} else {
alert(data.message || '비밀번호 초기화에 실패했습니다.');
}
} catch (error) {
console.error('Failed to reset password:', error);
alert('비밀번호 초기화에 실패했습니다.');
}
}
};