v0.1.47 - 관리자 계정 정리 기능 추가
This commit is contained in:
79
src/App.vue
79
src/App.vue
@@ -8,7 +8,12 @@ import MiniCalendar from './components/MiniCalendar.vue'
|
||||
import PlannerPage from './components/PlannerPage.vue'
|
||||
import SettingsDashboard from './components/SettingsDashboard.vue'
|
||||
import StatsDashboard from './components/StatsDashboard.vue'
|
||||
import { fetchAdminOverview } from './lib/adminApi'
|
||||
import {
|
||||
deleteAdminUser,
|
||||
fetchAdminOverview,
|
||||
revokeAdminUserSessions,
|
||||
updateAdminUserStatus,
|
||||
} from './lib/adminApi'
|
||||
import {
|
||||
clearAuthState,
|
||||
confirmVerification,
|
||||
@@ -107,10 +112,12 @@ const guideTooltipResetMessage = ref('')
|
||||
const hiddenGuideTooltips = ref(readHiddenGuideTooltips())
|
||||
const ddayDisabledDateKeys = ref(readDdayDisabledDateKeys())
|
||||
const adminBusy = ref(false)
|
||||
const adminActionUserId = ref(null)
|
||||
const adminMessage = ref('')
|
||||
const adminOverview = ref({
|
||||
totalUsers: 0,
|
||||
totalAdmins: 0,
|
||||
disabledUsers: 0,
|
||||
verifiedUsers: 0,
|
||||
activeUsers30d: 0,
|
||||
newUsers7d: 0,
|
||||
@@ -1678,6 +1685,7 @@ function clearAuthenticatedState() {
|
||||
adminOverview.value = {
|
||||
totalUsers: 0,
|
||||
totalAdmins: 0,
|
||||
disabledUsers: 0,
|
||||
verifiedUsers: 0,
|
||||
activeUsers30d: 0,
|
||||
newUsers7d: 0,
|
||||
@@ -1734,6 +1742,71 @@ async function loadAdminDashboard() {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleAdminUserStatus(user) {
|
||||
const willDisable = !user.disabledAt
|
||||
const confirmed = window.confirm(
|
||||
willDisable
|
||||
? `"${user.nickname}" 계정을 비활성화할까요? 즉시 로그인할 수 없고 현재 세션도 종료됩니다.`
|
||||
: `"${user.nickname}" 계정을 다시 사용할 수 있게 할까요?`,
|
||||
)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
adminActionUserId.value = user.id
|
||||
|
||||
try {
|
||||
const result = await updateAdminUserStatus(authToken.value, user.id, willDisable)
|
||||
adminMessage.value = result.message || '계정 상태를 변경했습니다.'
|
||||
await loadAdminDashboard()
|
||||
} catch (error) {
|
||||
adminMessage.value = error.message || '계정 상태를 변경하지 못했습니다.'
|
||||
} finally {
|
||||
adminActionUserId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function revokeAdminSessions(user) {
|
||||
const confirmed = window.confirm(`"${user.nickname}" 사용자를 현재 로그인된 모든 기기에서 로그아웃시킬까요?`)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
adminActionUserId.value = user.id
|
||||
|
||||
try {
|
||||
const result = await revokeAdminUserSessions(authToken.value, user.id)
|
||||
adminMessage.value = result.message || '사용자 세션을 정리했습니다.'
|
||||
await loadAdminDashboard()
|
||||
} catch (error) {
|
||||
adminMessage.value = error.message || '사용자 세션을 종료하지 못했습니다.'
|
||||
} finally {
|
||||
adminActionUserId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function removeAdminUser(user) {
|
||||
const confirmed = window.confirm(`"${user.nickname}" 계정을 삭제할까요? 플래너 기록과 목표 데이터도 함께 삭제됩니다.`)
|
||||
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
|
||||
adminActionUserId.value = user.id
|
||||
|
||||
try {
|
||||
const result = await deleteAdminUser(authToken.value, user.id)
|
||||
adminMessage.value = result.message || '사용자 계정을 삭제했습니다.'
|
||||
await loadAdminDashboard()
|
||||
} catch (error) {
|
||||
adminMessage.value = error.message || '사용자 계정을 삭제하지 못했습니다.'
|
||||
} finally {
|
||||
adminActionUserId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGoals() {
|
||||
if (!authToken.value) {
|
||||
return
|
||||
@@ -3118,7 +3191,11 @@ onBeforeUnmount(() => {
|
||||
:users="adminUsers"
|
||||
:recent-logins="adminRecentLogins"
|
||||
:busy="adminBusy"
|
||||
:action-busy-user-id="adminActionUserId"
|
||||
:message="adminMessage"
|
||||
@toggle-user-status="toggleAdminUserStatus"
|
||||
@revoke-user-sessions="revokeAdminSessions"
|
||||
@delete-user="removeAdminUser"
|
||||
/>
|
||||
|
||||
<StatsDashboard
|
||||
|
||||
Reference in New Issue
Block a user