기능검증 중
This commit is contained in:
@@ -185,6 +185,64 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정 관리 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-key me-2"></i>계정 관리</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- Google 연결 상태 -->
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-3 text-muted">Google 연결</div>
|
||||
<div class="col-9">
|
||||
<span v-if="userInfo.googleId" class="badge bg-success me-2">
|
||||
<i class="bi bi-check-circle me-1"></i>연결됨
|
||||
</span>
|
||||
<span v-if="userInfo.googleEmail" class="text-muted small">{{ userInfo.googleEmail }}</span>
|
||||
<span v-if="!userInfo.googleId" class="badge bg-secondary">미연결</span>
|
||||
<button
|
||||
v-if="userInfo.googleId && !isSelf"
|
||||
class="btn btn-sm btn-outline-warning ms-2"
|
||||
@click="unlinkGoogle"
|
||||
:disabled="isUnlinking"
|
||||
>
|
||||
<span v-if="isUnlinking" class="spinner-border spinner-border-sm me-1"></span>
|
||||
연결 해제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 비밀번호 상태 -->
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-3 text-muted">비밀번호</div>
|
||||
<div class="col-9">
|
||||
<span v-if="userInfo.hasPassword" class="badge bg-success me-2">
|
||||
<i class="bi bi-check-circle me-1"></i>설정됨
|
||||
</span>
|
||||
<span v-else class="badge bg-warning text-dark me-2">미설정</span>
|
||||
<button
|
||||
v-if="!isSelf"
|
||||
class="btn btn-sm btn-outline-danger"
|
||||
@click="resetPassword"
|
||||
:disabled="isResetting"
|
||||
>
|
||||
<span v-if="isResetting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
비밀번호 초기화
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 마지막 로그인 -->
|
||||
<div class="row align-items-center">
|
||||
<div class="col-3 text-muted">마지막 로그인</div>
|
||||
<div class="col-9">
|
||||
{{ userInfo.lastLoginAt ? formatDateTime(userInfo.lastLoginAt) : '없음' }}
|
||||
<code v-if="userInfo.lastLoginIp" class="ms-2">{{ userInfo.lastLoginIp }}</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 위험 영역 -->
|
||||
<div class="card border-danger" v-if="!isSelf">
|
||||
<div class="card-header bg-danger text-white">
|
||||
@@ -236,6 +294,8 @@ const employeeId = computed(() => route.params.id as string)
|
||||
const isLoading = ref(true)
|
||||
const isSaving = ref(false)
|
||||
const isDeleting = ref(false)
|
||||
const isResetting = ref(false)
|
||||
const isUnlinking = ref(false)
|
||||
const showDeleteModal = ref(false)
|
||||
const currentUser = ref<any>(null)
|
||||
const userInfo = ref<any>(null)
|
||||
@@ -345,6 +405,45 @@ async function deleteUser() {
|
||||
}
|
||||
}
|
||||
|
||||
async function resetPassword() {
|
||||
if (!confirm('비밀번호를 초기화하시겠습니까?\n임시 비밀번호가 생성되어 화면에 표시됩니다.')) return
|
||||
|
||||
isResetting.value = true
|
||||
try {
|
||||
const res = await $fetch<any>(`/api/admin/user/reset-password`, {
|
||||
method: 'POST',
|
||||
body: { employeeId: parseInt(employeeId.value) }
|
||||
})
|
||||
|
||||
alert(`비밀번호가 초기화되었습니다.\n\n임시 비밀번호: ${res.tempPassword}\n\n사용자에게 전달해주세요.`)
|
||||
await loadUserInfo()
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
alert(e.data?.message || '비밀번호 초기화에 실패했습니다.')
|
||||
} finally {
|
||||
isResetting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function unlinkGoogle() {
|
||||
if (!confirm('Google 계정 연결을 해제하시겠습니까?')) return
|
||||
|
||||
isUnlinking.value = true
|
||||
try {
|
||||
await $fetch(`/api/employee/${employeeId.value}/unlink-google`, {
|
||||
method: 'POST'
|
||||
})
|
||||
|
||||
alert('Google 계정 연결이 해제되었습니다.')
|
||||
await loadUserInfo()
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
alert(e.data?.message || 'Google 연결 해제에 실패했습니다.')
|
||||
} finally {
|
||||
isUnlinking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return '-'
|
||||
const d = new Date(dateStr)
|
||||
|
||||
133
frontend/auth/set-password.vue
Normal file
133
frontend/auth/set-password.vue
Normal file
@@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<div class="set-password-container">
|
||||
<div class="set-password-card">
|
||||
<div class="text-center mb-4">
|
||||
<i class="bi bi-shield-lock display-1 text-primary"></i>
|
||||
<h3 class="mt-3">비밀번호 설정</h3>
|
||||
<p class="text-muted">
|
||||
비상시 로그인을 위해 비밀번호를 설정해주세요.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
Google 계정으로 로그인되었습니다.<br>
|
||||
비밀번호를 설정하면 이메일/비밀번호로도 로그인할 수 있습니다.
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="handleSetPassword">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">새 비밀번호</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="newPassword"
|
||||
placeholder="8자 이상 입력"
|
||||
required
|
||||
minlength="8"
|
||||
/>
|
||||
<small class="text-muted">8자 이상, 영문+숫자 조합 권장</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="form-label">비밀번호 확인</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="confirmPassword"
|
||||
placeholder="비밀번호 다시 입력"
|
||||
required
|
||||
/>
|
||||
<small v-if="confirmPassword && newPassword !== confirmPassword" class="text-danger">
|
||||
비밀번호가 일치하지 않습니다.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary w-100 mb-3"
|
||||
:disabled="isSubmitting || !canSubmit"
|
||||
>
|
||||
<span v-if="isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>설정 중...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-check-lg me-2"></i>비밀번호 설정
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="/" class="text-muted small">나중에 설정하기 →</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="alert alert-danger mt-3" v-if="errorMessage">
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<div class="alert alert-success mt-3" v-if="successMessage">
|
||||
<i class="bi bi-check-circle me-2"></i>{{ successMessage }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
definePageMeta({ layout: false })
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const newPassword = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
return newPassword.value.length >= 8 && newPassword.value === confirmPassword.value
|
||||
})
|
||||
|
||||
async function handleSetPassword() {
|
||||
if (!canSubmit.value) return
|
||||
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
|
||||
try {
|
||||
await $fetch('/api/auth/set-password', {
|
||||
method: 'POST',
|
||||
body: { password: newPassword.value }
|
||||
})
|
||||
|
||||
successMessage.value = '비밀번호가 설정되었습니다. 메인 페이지로 이동합니다.'
|
||||
|
||||
setTimeout(() => {
|
||||
router.push('/')
|
||||
}, 1500)
|
||||
} catch (e: any) {
|
||||
errorMessage.value = e.data?.message || e.message || '비밀번호 설정에 실패했습니다.'
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.set-password-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 2rem;
|
||||
}
|
||||
.set-password-card {
|
||||
background: white;
|
||||
border-radius: 1rem;
|
||||
padding: 2rem;
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
@@ -361,6 +361,10 @@ const vcsForm = ref({ serverId: '', vcsUsername: '', vcsEmail: '', authType: 'pa
|
||||
const isEditing = ref(false)
|
||||
const isSaving = ref(false)
|
||||
|
||||
// 비밀번호 변경 관련
|
||||
const pwForm = ref({ currentPassword: '', newPassword: '', confirmPassword: '' })
|
||||
const isChangingPw = ref(false)
|
||||
|
||||
const editForm = ref({
|
||||
employeeName: '',
|
||||
company: '',
|
||||
@@ -511,4 +515,35 @@ async function deleteVcsAccount(account: any) {
|
||||
alert(e.data?.message || '삭제에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
// 비밀번호 변경
|
||||
async function changePassword() {
|
||||
if (!pwForm.value.newPassword || pwForm.value.newPassword.length < 8) {
|
||||
alert('새 비밀번호는 8자 이상이어야 합니다.')
|
||||
return
|
||||
}
|
||||
if (pwForm.value.newPassword !== pwForm.value.confirmPassword) {
|
||||
alert('새 비밀번호가 일치하지 않습니다.')
|
||||
return
|
||||
}
|
||||
|
||||
isChangingPw.value = true
|
||||
try {
|
||||
await $fetch('/api/auth/change-password', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
currentPassword: pwForm.value.currentPassword || null,
|
||||
newPassword: pwForm.value.newPassword,
|
||||
confirmPassword: pwForm.value.confirmPassword
|
||||
}
|
||||
})
|
||||
alert('비밀번호가 변경되었습니다.')
|
||||
pwForm.value = { currentPassword: '', newPassword: '', confirmPassword: '' }
|
||||
loadUserInfo()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '비밀번호 변경에 실패했습니다.')
|
||||
} finally {
|
||||
isChangingPw.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user