Hi,
I’m trying to change userId as an admin role. I can’t figure out what’s the issue.
Profiles = new Mongo.Collection("experts");
Profiles.attachSchema(
new SimpleSchema({
userId: {
type: String,
autoValue: function() {
if (this.isInsert) {
return Meteor.userId();
} else if (this.isUpsert) {
return {
$setOnInsert: Meteor.userId()
};
} else {
this.unset();
}
}
},
})
);
Profiles.allow({
insert: function(userId, doc) {
return userId && doc && userId === doc.userId;
},
update: function(userId, doc, fieldNames, modifier) {
return Roles.userIsInRole(userId, ['admin']) || (!_.contains(fieldNames, 'randomSorter') && !_.contains(fieldNames, 'htmlDescription') && !_.contains(fieldNames, 'status') && userId && doc && userId === doc.userId);
},
remove: function(userId, doc) {
return Roles.userIsInRole(userId, ['admin']) || (userId && doc && userId === doc.userId);
},
fetch: ['userId']
});
Any idea how do I allow the admin to edit the userId field?