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)) {
|
if (await compare(password, dbUser.password)) {
|
||||||
const payload = {
|
const payload = {
|
||||||
userId: dbUser._id,
|
userId: dbUser._id,
|
||||||
|
builder: dbUser.builder,
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = jwt.sign(payload, process.env.JWT_SECRET, {
|
const token = jwt.sign(payload, process.env.JWT_SECRET, {
|
||||||
|
|
|
@ -14,15 +14,15 @@ function buildUserSaveValidation() {
|
||||||
email: Joi.string(),
|
email: Joi.string(),
|
||||||
password: Joi.string().allow(null, ""),
|
password: Joi.string().allow(null, ""),
|
||||||
builder: Joi.object({
|
builder: Joi.object({
|
||||||
global: Joi.boolean().allow(undefined),
|
global: Joi.boolean().optional(),
|
||||||
apps: Joi.array().allow(undefined),
|
apps: Joi.array().optional(),
|
||||||
}).unknown(true).allow(undefined),
|
}).unknown(true).optional(),
|
||||||
// maps appId -> roleId for the user
|
// maps appId -> roleId for the user
|
||||||
roles: Joi.object()
|
roles: Joi.object()
|
||||||
.pattern(/.*/, Joi.string())
|
.pattern(/.*/, Joi.string())
|
||||||
.required()
|
.required()
|
||||||
.unknown(true)
|
.unknown(true)
|
||||||
}).required().unknown(true).allow(undefined))
|
}).required().unknown(true).optional())
|
||||||
}
|
}
|
||||||
|
|
||||||
router
|
router
|
||||||
|
|
Loading…
Reference in New Issue