deleteWork secure and schema update
This commit is contained in:
parent
0e571e8942
commit
f2fa1fdc20
@ -29,6 +29,8 @@ work.schema = new SimpleSchema({
|
||||
name: {type: String},
|
||||
class: {type: String},
|
||||
dueDate: {type: Date},
|
||||
creator: {type: String},
|
||||
comments: {type: [String]},
|
||||
submittor: {type: String, optional: true},
|
||||
confirmations: {type: [String], optional: true},
|
||||
reports: {type: [String], optional: true},
|
||||
|
||||
@ -178,15 +178,20 @@ Meteor.methods({
|
||||
input.reports = [];
|
||||
input.done = [];
|
||||
input.numberdone = 0;
|
||||
input.creator = Meteor.userId();
|
||||
input.comments = [];
|
||||
work.insert(input);
|
||||
}
|
||||
|
||||
},
|
||||
'deleteWork': function(workid) {
|
||||
// Add security here
|
||||
work.remove({
|
||||
_id: workid
|
||||
});
|
||||
'deleteWork': function(workId) {
|
||||
var currentclass = classes.findOne({_id: work.findOne({_id: workId}).class});
|
||||
var authorized = currentclass.moderators.push(currentclass.admin);
|
||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) || authorized.indexOf(Meteor.userId()) != -1) {
|
||||
work.remove({
|
||||
_id: workid
|
||||
});
|
||||
}
|
||||
},
|
||||
'editProfile': function(change) {
|
||||
current = Meteor.user().profile;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user