diff --git a/bin/cli-setup b/bin/cli-setup index 282a8a2d7..572e8c7fc 100755 --- a/bin/cli-setup +++ b/bin/cli-setup @@ -15,6 +15,7 @@ const SetupService = require('../services/setup'); const UsersService = require('../services/users'); const MigrationService = require('../services/migration'); const errors = require('../errors'); +const Context = require('../graph/context'); // Register the shutdown criteria. util.onshutdown([() => mongoose.disconnect()]); @@ -184,7 +185,8 @@ const performSetup = async () => { }, ]); - let { user: newUser } = await SetupService.setup({ + const ctx = Context.forSystem(); + let { user: newUser } = await SetupService.setup(ctx, { settings: settings.toObject(), user: { email: user.email, diff --git a/routes/api/v1/setup.js b/routes/api/v1/setup.js index c3cf9518e..553e42f44 100644 --- a/routes/api/v1/setup.js +++ b/routes/api/v1/setup.js @@ -21,7 +21,10 @@ router.post('/', async (req, res, next) => { const { settings, user: { email, password, username } } = req.body; try { - await SetupService.setup({ settings, user: { email, password, username } }); + await SetupService.setup(req.context, { + settings, + user: { email, password, username }, + }); res.status(204).end(); } catch (err) { return next(err); diff --git a/services/setup.js b/services/setup.js index 29f84ff40..84f915ff2 100644 --- a/services/setup.js +++ b/services/setup.js @@ -61,7 +61,7 @@ module.exports = class SetupService { /** * This will perform the setup. */ - static async setup({ settings, user: { email, password, username } }) { + static async setup(ctx, { settings, user: { email, password, username } }) { // Validate the settings first. await SetupService.validate({ settings, @@ -79,7 +79,12 @@ module.exports = class SetupService { // Settings are created! Create the user. // Create the user. - let user = await UsersService.createLocalUser(email, password, username); + let user = await UsersService.createLocalUser( + ctx, + email, + password, + username + ); // Grant them administrative privileges and confirm the email account. await Promise.all([