Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
withFields(() => ({
model: ref({ instanceOf: [], refNameField: "modelName" }),
modelName: string(),
group: ref({
instanceOf: SecurityGroup
})
}))
)(createBase());
withFields(() => ({
model: ref({ instanceOf: [], refNameField: "modelClassId" }),
modelClassId: string(),
role: ref({
instanceOf: SecurityRole
})
}))
)(createBase());
withFields(instance => ({
form: fields({
instanceOf: withFields({
parent: ref({
parent: instance,
instanceOf: Form,
validation: validation.create("required")
}),
revision: ref({
parent: instance,
instanceOf: Form,
validation: validation.create("required")
})
})()
}),
data: object({ validation: validation.create("required") }),
meta: fields({
instanceOf: withFields({
ip: string({ validation: validation.create("required") }),
locale: string({ validation: validation.create("required") }),
withFields(() => ({
model: ref({ instanceOf: [], refNameField: "modelName" }),
modelName: string(),
group: ref({
instanceOf: SecurityGroup
})
}))
)(createBase());
withFields(instance => ({
form: fields({
instanceOf: withFields({
parent: ref({
parent: instance,
instanceOf: Form,
validation: validation.create("required")
}),
revision: ref({
parent: instance,
instanceOf: Form,
validation: validation.create("required")
})
})()
}),
data: object({ validation: validation.create("required") }),
meta: fields({
instanceOf: withFields({
ip: string({ validation: validation.create("required") }),
locale: string({ validation: validation.create("required") }),
submittedOn: skipOnPopulate()(
date({ validation: validation.create("required") })
)
})()
}),
return bcrypt.hashSync(value, bcrypt.genSaltSync(10));
}
return instance.password;
})(
string({
validation: validation.create("required")
})
),
firstName: string(),
lastName: string(),
roles: ref({
list: true,
instanceOf: [SecurityRole, "model"],
using: [SecurityRoles2Models, "role"]
}),
groups: ref({
list: true,
instanceOf: [SecurityGroup, "model"],
using: [SecurityGroups2Models, "group"]
}),
avatar: context.commodo.fields.id()
})),
withProps(instance => ({
withFields(instance => ({
category: ref({ instanceOf: PbCategory, validation: validation.create("required") }),
publishedOn: skipOnPopulate()(date()),
title: onSet(value => (instance.locked ? instance.title : value))(
string({ validation: validation.create("required") })
),
snippet: onSet(value => (instance.locked ? instance.snippet : value))(string()),
url: onSet(value => (instance.locked ? instance.url : value))(
string({ validation: validation.create("required") })
),
content: onSet(value => (instance.locked ? instance.content : value))(
content({ context })
),
settings: onSet(value => (instance.locked ? instance.settings : value))(
fields({
instanceOf: PbPageSettings
})
),
withFields(() => ({
description: string(),
name: string(),
slug: string(),
system: boolean(),
roles: ref({
list: true,
instanceOf: [SecurityRole, "model"],
using: [SecurityRoles2Models, "role"]
})
})),
withHooks({
withFields(() => ({
model: ref({ instanceOf: [], refNameField: "modelClassId" }),
modelClassId: string(),
role: ref({
instanceOf: SecurityRole
})
}))
)(createBase());
validation: validation.create("required")
})
),
password: onSet(value => {
if (value) {
return bcrypt.hashSync(value, bcrypt.genSaltSync(10));
}
return instance.password;
})(
string({
validation: validation.create("required")
})
),
firstName: string(),
lastName: string(),
roles: ref({
list: true,
instanceOf: [SecurityRole, "model"],
using: [SecurityRoles2Models, "role"]
}),
groups: ref({
list: true,
instanceOf: [SecurityGroup, "model"],
using: [SecurityGroups2Models, "group"]
}),
avatar: context.commodo.fields.id()
})),
withProps(instance => ({