fix: 🐛 first user gets admin

Closes #9620

Co-authored-by: @Johann150
This commit is contained in:
ThatOneCalculator 2023-02-12 20:18:45 -08:00
parent 95fcac3e55
commit abff66eada
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
3 changed files with 3 additions and 0 deletions

View File

@ -107,6 +107,7 @@ export async function signup(opts: {
isAdmin:
(await Users.countBy({
host: IsNull(),
isAdmin: true,
})) === 0,
}),
);

View File

@ -35,6 +35,7 @@ export default define(meta, paramDef, async (ps, _me) => {
const noUsers =
(await Users.countBy({
host: IsNull(),
isAdmin: true,
})) === 0;
if (!(noUsers || me?.isAdmin)) throw new Error("access denied");

View File

@ -489,6 +489,7 @@ export default define(meta, paramDef, async (ps, me) => {
requireSetup:
(await Users.countBy({
host: IsNull(),
isAdmin: true,
})) === 0,
}
: {}),