Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
success: true
});
})
);
// create new user
router.post(
"/",
requireAdminStatus,
celebrate({
body: Joi.object().keys({
firstName: Joi.string().required(),
lastName: Joi.string().required(),
oauthId: Joi.string().required(),
propicUrl: Joi.string(),
isApproved: Joi.boolean().default(false),
role: Joi.string().required(),
location: Joi.string().required(),
email: Joi.string().required()
})
}),
errorWrap(async (req, res) => {
const data = req.body;
const newUser = new User({
firstName: data.firstName,
lastName: data.lastName,
oauthId: data.oauthId,
propicUrl: data.propicUrl,
role: data.role,
location: data.location,
email: data.email
});
};
res.status(ret.code).json(ret);
})
);
// approve user
router.put(
"/:user_id/approve",
requireAdminStatus,
celebrate({
body: Joi.object().keys({
firstName: Joi.string(),
lastName: Joi.string(),
oauthId: Joi.string(),
propicUrl: Joi.string(),
isApproved: Joi.boolean(),
role: Joi.string(),
location: Joi.string(),
email: Joi.string()
})
}),
errorWrap(async (req, res) => {
const userId = req.params.user_id;
const user = await User.findByIdAndUpdate(
userId,
{ $set: { isApproved: true } },
{ new: true }
);
const ret = user
? {
code: 200,