feat: introduction of 'system user'

This commit is contained in:
DecDuck
2024-11-16 16:18:15 +11:00
parent 87230fb0e7
commit 2c21a235b2
2 changed files with 26 additions and 3 deletions

View File

@ -12,4 +12,28 @@ export default defineNitroPlugin(async (nitro) => {
nitro.hooks.hookOnce("close", async () => {
await applicationSettings.waitForWrite();
});
// Ensure system user exists
// The system user owns any user-based code
// that we want to re-use for the app
// e.g. notifications
await prisma.user.upsert({
where: {
id: "system",
},
create: {
id: "system",
admin: true,
displayName: "System",
username: "system",
email: "system@drop",
profilePicture: "",
},
update: {
admin: true,
authMecs: { set: [] },
clients: { set: [] },
},
});
});

View File

@ -5,6 +5,7 @@ export default defineNitroPlugin(async (nitro) => {
if (userCount != 0) return;
// This setup runs every time the server sets up,
// but has not been configured
// so it should be in-place
// Create admin invitation
@ -15,12 +16,10 @@ export default defineNitroPlugin(async (nitro) => {
create: {
id: "admin",
isAdmin: true,
expires: new Date('4096-01-01')
expires: new Date("4096-01-01"),
},
update: {
isAdmin: true,
},
});
});