Setup wizard & 0.3.0 release (#146)

* fix: small merge fixes

* feat: initial setup wizard

* fix: last few localization items

* fix: lint

* fix: bump version
This commit is contained in:
DecDuck
2025-07-31 20:41:02 +10:00
committed by GitHub
parent ed99e020df
commit e4c8d42cc8
25 changed files with 684 additions and 279 deletions

View File

@ -3,7 +3,7 @@ import aclManager from "~/server/internal/acls";
import authManager from "~/server/internal/auth";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, ["auth:read"]);
const allowed = await aclManager.allowSystemACL(h3, ["auth:read", "setup"]);
if (!allowed) throw createError({ statusCode: 403 });
const enabledAuthManagers = authManager.getAuthProviders();

View File

@ -14,6 +14,7 @@ const CreateInvite = SharedRegisterValidator.partial()
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"auth:simple:invitation:new",
"setup",
]);
if (!allowed) throw createError({ statusCode: 403 });

View File

@ -0,0 +1,7 @@
import aclManager from "~/server/internal/acls";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, []);
if (!allowed) return false;
return true;
});

View File

@ -12,6 +12,7 @@ export default defineEventHandler<{ body: typeof DeleteLibrarySource.infer }>(
async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"library:sources:delete",
"setup",
]);
if (!allowed) throw createError({ statusCode: 403 });

View File

@ -5,7 +5,10 @@ import libraryManager from "~/server/internal/library";
export type WorkingLibrarySource = LibraryModel & { working: boolean };
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, ["library:sources:read"]);
const allowed = await aclManager.allowSystemACL(h3, [
"library:sources:read",
"setup",
]);
if (!allowed) throw createError({ statusCode: 403 });
const sources = await libraryManager.fetchLibraries();

View File

@ -16,6 +16,7 @@ export default defineEventHandler<{ body: typeof UpdateLibrarySource.infer }>(
async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"library:sources:update",
"setup",
]);
if (!allowed) throw createError({ statusCode: 403 });

View File

@ -18,6 +18,7 @@ export default defineEventHandler<{ body: typeof CreateLibrarySource.infer }>(
async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, [
"library:sources:new",
"setup",
]);
if (!allowed) throw createError({ statusCode: 403 });

View File

@ -0,0 +1,20 @@
import { APITokenMode } from "~/prisma/client/enums";
import aclManager from "~/server/internal/acls";
import prisma from "~/server/internal/db/database";
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, ["setup"]);
if (!allowed)
throw createError({
statusCode: 403,
statusMessage: "Must use a setup token.",
});
await prisma.aPIToken.deleteMany({
where: {
mode: APITokenMode.System,
acls: {
hasSome: ["setup"],
},
},
});
});