mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
make comment's postId uneditable in schema (fix #1231)
This commit is contained in:
parent
bb23d9b8b2
commit
baa38bfa40
2 changed files with 9 additions and 4 deletions
|
@ -143,7 +143,7 @@ Comments.schema = new SimpleSchema({
|
|||
optional: true,
|
||||
// regEx: SimpleSchema.RegEx.Id,
|
||||
max: 500,
|
||||
editableBy: ["member", "admin"], // TODO: should users be able to set postId, but not modify it?
|
||||
// editableBy: ["member", "admin"], // TODO: should users be able to set postId, but not modify it?
|
||||
autoform: {
|
||||
omit: true // never show this
|
||||
}
|
||||
|
|
|
@ -111,9 +111,14 @@ Meteor.methods({
|
|||
// clear restricted properties
|
||||
_.keys(comment).forEach(function (fieldName) {
|
||||
|
||||
var field = schema[fieldName];
|
||||
if (!Users.can.submitField(user, field)) {
|
||||
throw new Meteor.Error("disallowed_property", i18n.t('disallowed_property_detected') + ": " + fieldName);
|
||||
// make an exception for postId, which should be setable but not modifiable
|
||||
if (fieldName === "postId") {
|
||||
// ok
|
||||
} else {
|
||||
var field = schema[fieldName];
|
||||
if (!Users.can.submitField(user, field)) {
|
||||
throw new Meteor.Error("disallowed_property", i18n.t('disallowed_property_detected') + ": " + fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue