mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-21 17:05:22 +03:00
feat: add delete oauth app for admin
This commit is contained in:
parent
2e7979817a
commit
ba5b89d5b8
4 changed files with 22 additions and 0 deletions
|
@ -10,6 +10,8 @@ NUXT_CLOUDFLARE_API_TOKEN=
|
|||
NUXT_STORAGE_DRIVER=
|
||||
NUXT_STORAGE_FS_BASE=
|
||||
|
||||
NUXT_ADMIN_KEY=
|
||||
|
||||
NUXT_PUBLIC_DISABLE_VERSION_CHECK=
|
||||
|
||||
NUXT_GITHUB_CLIENT_ID=
|
||||
|
|
|
@ -76,6 +76,7 @@ export default defineNuxtConfig({
|
|||
},
|
||||
},
|
||||
runtimeConfig: {
|
||||
adminKey: '',
|
||||
cloudflare: {
|
||||
accountId: '',
|
||||
namespaceId: '',
|
||||
|
|
13
server/api/[server]/clear.ts
Normal file
13
server/api/[server]/clear.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { deleteApp } from '~~/server/shared'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { server } = getRouterParams(event)
|
||||
const { key } = getQuery(event)
|
||||
|
||||
if (key !== String(useRuntimeConfig().adminKey))
|
||||
return { status: false, error: 'incorrect key' }
|
||||
|
||||
await deleteApp(server)
|
||||
|
||||
return { status: true }
|
||||
})
|
|
@ -63,6 +63,12 @@ export async function getApp(origin: string, server: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function deleteApp(server: string) {
|
||||
const keys = (await storage.getKeys('servers:')).filter(k => k.endsWith(`${server}.json`))
|
||||
for (const key of keys)
|
||||
await storage.removeItem(key)
|
||||
}
|
||||
|
||||
export async function listServers() {
|
||||
const keys = await storage.getKeys('servers:')
|
||||
const servers = new Set<string>()
|
||||
|
|
Loading…
Reference in a new issue