joi syntax, adding db user builder key to cookie
This commit is contained in:
parent
0f59546169
commit
eef989f375
|
@ -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, {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue