diff --git a/.config/example.yml b/.config/example.yml index 0265c8cc2af53ad60697e11d2ea12ad64d4b6e1e..44c58ccf30ae7c7fb031da402f83ef04eea96433 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -110,6 +110,10 @@ drive: # accessKey: XXX # secretKey: YYY +# If enabled: +# The first account created is automatically marked as Admin. +autoAdmin: true + # # Below settings are optional # diff --git a/src/config/load.ts b/src/config/load.ts index 738d6427f3d4a95466f74c4b0eb6f5f40f1ebef8..56a8ff0abde94c824c835a87704112fb37efa90c 100644 --- a/src/config/load.ts +++ b/src/config/load.ts @@ -49,6 +49,8 @@ export default function load() { if (config.localDriveCapacityMb == null) config.localDriveCapacityMb = 256; if (config.remoteDriveCapacityMb == null) config.remoteDriveCapacityMb = 8; + if (config.autoAdmin == null) config.autoAdmin = false; + return Object.assign(config, mixin); } diff --git a/src/config/types.ts b/src/config/types.ts index a3c761cc641281c8323364e870c8a883901c5788..f5049beb80d53b8777d09b2c3e2314eadcae23e3 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -58,6 +58,8 @@ export type Source = { config?: any; }; + autoAdmin?: boolean; + /** * ゴーストアカウントã®ID */ diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index d6eba69817a26d520c61e985775f29c17638d156..ab7342d6b87fbb5e40b281c08c319f0ad9781d8c 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -67,6 +67,8 @@ export default async (ctx: Koa.Context) => { return; } + const usersCount = await User.count({}); + // Fetch exist user that same username const usernameExist = await User .count({ @@ -106,6 +108,7 @@ export default async (ctx: Koa.Context) => { token: secret, email: null, password: hash, + isAdmin: config.autoAdmin && usersCount === 0, profile: { bio: null, birthday: null,