From 77c98009b89c11fef72f6d3a800c14dd039e7af3 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 14 Apr 2021 13:22:57 +0100 Subject: [PATCH] joi syntax, adding db user builder key to cookie --- packages/auth/src/middleware/passport/local.js | 1 + packages/worker/src/api/routes/admin/index.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/auth/src/middleware/passport/local.js b/packages/auth/src/middleware/passport/local.js index 5a2221499a..2984d2d7e3 100644 --- a/packages/auth/src/middleware/passport/local.js +++ b/packages/auth/src/middleware/passport/local.js @@ -39,6 +39,7 @@ exports.authenticate = async function(username, password, done) { if (await compare(password, dbUser.password)) { const payload = { userId: dbUser._id, + builder: dbUser.builder, } const token = jwt.sign(payload, process.env.JWT_SECRET, { diff --git a/packages/worker/src/api/routes/admin/index.js b/packages/worker/src/api/routes/admin/index.js index 2d46174c68..77c46278d1 100644 --- a/packages/worker/src/api/routes/admin/index.js +++ b/packages/worker/src/api/routes/admin/index.js @@ -14,15 +14,15 @@ function buildUserSaveValidation() { email: Joi.string(), password: Joi.string().allow(null, ""), builder: Joi.object({ - global: Joi.boolean().allow(undefined), - apps: Joi.array().allow(undefined), - }).unknown(true).allow(undefined), + global: Joi.boolean().optional(), + apps: Joi.array().optional(), + }).unknown(true).optional(), // maps appId -> roleId for the user roles: Joi.object() .pattern(/.*/, Joi.string()) .required() .unknown(true) - }).required().unknown(true).allow(undefined)) + }).required().unknown(true).optional()) } router