release: PicHost v1.0.0
Publish Docker image / build-and-push (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
Publish Docker image / build-and-push (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
Multi-user image hosting with RBAC, upload preferences, and admin settings.
This commit is contained in:
commit
bc4cba7e52
115 files changed
+26508
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { requireAdminAuth } from '../../../utils/access'
|
||||
import { createApiError } from '../../../utils/api-error'
|
||||
import {
|
||||
generateApiUploadToken,
|
||||
setSetting,
|
||||
SETTINGS_API_UPLOAD_TOKEN
|
||||
} from '../../../utils/db'
|
||||
import { isApiUploadTokenEnvConfigured } from '../../../utils/env'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireAdminAuth(event)
|
||||
|
||||
if (isApiUploadTokenEnvConfigured(event)) {
|
||||
createApiError(
|
||||
event,
|
||||
'CONFLICT',
|
||||
'API_UPLOAD_TOKEN 已在环境变量中配置,无法在后台重新生成',
|
||||
409
|
||||
)
|
||||
}
|
||||
|
||||
const token = generateApiUploadToken()
|
||||
setSetting(SETTINGS_API_UPLOAD_TOKEN, token)
|
||||
|
||||
return {
|
||||
apiUploadToken: token,
|
||||
tokenSource: 'db' as const
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user