v0.1.47 - 관리자 계정 정리 기능 추가
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { buildApiUrl, toUserFacingApiError } from './apiBase'
|
||||
|
||||
async function request(path, token) {
|
||||
async function request(path, token, { method = 'GET', body } = {}) {
|
||||
const hasBody = body !== undefined
|
||||
const response = await fetch(buildApiUrl(path), {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
...(hasBody ? { 'Content-Type': 'application/json' } : {}),
|
||||
},
|
||||
body: hasBody ? JSON.stringify(body) : undefined,
|
||||
})
|
||||
|
||||
const data = await response.json().catch(() => ({}))
|
||||
@@ -19,3 +23,22 @@ async function request(path, token) {
|
||||
export async function fetchAdminOverview(token) {
|
||||
return request('/api/admin/overview', token)
|
||||
}
|
||||
|
||||
export async function updateAdminUserStatus(token, userId, disabled) {
|
||||
return request(`/api/admin/users/${userId}/status`, token, {
|
||||
method: 'PUT',
|
||||
body: { disabled },
|
||||
})
|
||||
}
|
||||
|
||||
export async function revokeAdminUserSessions(token, userId) {
|
||||
return request(`/api/admin/users/${userId}/revoke-sessions`, token, {
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteAdminUser(token, userId) {
|
||||
return request(`/api/admin/users/${userId}`, token, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user