feat: optimize user management and add account deletion

This commit is contained in:
巫凤萍
2026-08-07 17:08:56 +08:00
parent 5670a7939b
commit 1f1887c860
5 changed files with 329 additions and 23 deletions

View File

@@ -23,6 +23,23 @@ test("builds the KOC LOOP product shell", async () => {
await access(new URL("../dist/client/assets", import.meta.url));
});
test("stacks user management and securely removes departed accounts", async () => {
const [usersPage, usersRoute, globalCss] = await Promise.all([
readFile(new URL("../app/users-page.tsx", import.meta.url), "utf8"),
readFile(new URL("../app/api/users/route.ts", import.meta.url), "utf8"),
readFile(new URL("../app/globals.css", import.meta.url), "utf8"),
]);
assert.match(globalCss, /\.user-management-layout\s*\{[^}]*grid-template-columns:\s*1fr/s);
assert.match(usersPage, /删除账号/);
assert.match(usersPage, /role="alertdialog"/);
assert.match(usersRoute, /body\.action === "delete"/);
assert.match(usersRoute, /不能删除当前登录账号/);
assert.match(usersRoute, /不能删除超级管理员账号/);
assert.match(usersRoute, /DELETE FROM auth_sessions WHERE user_id = \?/);
assert.match(usersRoute, /DELETE FROM users WHERE id = \? AND role <> 'super_admin'/);
});
test("ships persistence, uploads, metadata, and no starter preview", async () => {
const [adminApp, layout, packageJson, hosting] = await Promise.all([
readFile(new URL("../app/admin-app.tsx", import.meta.url), "utf8"),