fixed some missing calls to service

This commit is contained in:
Wyatt Johnson
2018-03-12 16:54:18 -06:00
parent ccda23ec60
commit da6b5c7f36
3 changed files with 14 additions and 4 deletions
+3 -1
View File
@@ -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,
+4 -1
View File
@@ -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);
+7 -2
View File
@@ -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([