joi syntax, adding db user builder key to cookie

This commit is contained in:
Martin McKeaveney 2021-04-14 13:22:57 +01:00
parent 0f59546169
commit eef989f375
2 changed files with 5 additions and 4 deletions

View File

@ -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, {

View File

@ -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