added error system
This commit is contained in:
parent
550f96aa86
commit
7aed50f2a3
@ -124,6 +124,8 @@ Meteor.methods({
|
|||||||
status: stat,
|
status: stat,
|
||||||
creator: Meteor.userId()
|
creator: Meteor.userId()
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'deleteSchool': function(schoolId) {
|
'deleteSchool': function(schoolId) {
|
||||||
@ -131,6 +133,8 @@ Meteor.methods({
|
|||||||
schools.remove({
|
schools.remove({
|
||||||
_id: schoolId
|
_id: schoolId
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'createClass': function(input) {
|
'createClass': function(input) {
|
||||||
@ -223,6 +227,8 @@ Meteor.methods({
|
|||||||
}, {
|
}, {
|
||||||
$set: set
|
$set: set
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'untrackUserInClass': function(input) {
|
'untrackUserInClass': function(input) {
|
||||||
@ -249,6 +255,8 @@ Meteor.methods({
|
|||||||
}, {
|
}, {
|
||||||
$set: set
|
$set: set
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'deleteClass': function(classid) {
|
'deleteClass': function(classid) {
|
||||||
@ -274,6 +282,8 @@ Meteor.methods({
|
|||||||
classes.remove({
|
classes.remove({
|
||||||
_id: classid
|
_id: classid
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'createWork': function(input) {
|
'createWork': function(input) {
|
||||||
@ -300,6 +310,8 @@ Meteor.methods({
|
|||||||
input.numberdone = 0;
|
input.numberdone = 0;
|
||||||
input.comments = [];
|
input.comments = [];
|
||||||
work.insert(input);
|
work.insert(input);
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -352,7 +364,7 @@ Meteor.methods({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw "Unauthorized.";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'addComment': function(input) {
|
'addComment': function(input) {
|
||||||
@ -376,6 +388,8 @@ Meteor.methods({
|
|||||||
time: new Date()
|
time: new Date()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'toggleWork': function(input) {
|
'toggleWork': function(input) {
|
||||||
@ -397,6 +411,8 @@ Meteor.methods({
|
|||||||
}, {
|
}, {
|
||||||
$set: workobject
|
$set: workobject
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'deleteWork': function(workId) {
|
'deleteWork': function(workId) {
|
||||||
@ -412,6 +428,8 @@ Meteor.methods({
|
|||||||
work.remove({
|
work.remove({
|
||||||
_id: workId
|
_id: workId
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'editProfile': function(change) {
|
'editProfile': function(change) {
|
||||||
@ -442,9 +460,9 @@ Meteor.methods({
|
|||||||
profile: current
|
profile: current
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return 1;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'joinClass': function(input) {
|
'joinClass': function(input) {
|
||||||
@ -476,9 +494,9 @@ Meteor.methods({
|
|||||||
profile: current
|
profile: current
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return 1;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'joinPrivateClass': function(input) {
|
'joinPrivateClass': function(input) {
|
||||||
@ -507,7 +525,7 @@ Meteor.methods({
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'leaveClass': function(change) {
|
'leaveClass': function(change) {
|
||||||
@ -536,7 +554,7 @@ Meteor.methods({
|
|||||||
subscribers: newstudents
|
subscribers: newstudents
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return 1;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw "You are currently the admin of this class. Transfer ownership in order to leave this class.";
|
throw "You are currently the admin of this class. Transfer ownership in order to leave this class.";
|
||||||
}
|
}
|
||||||
@ -549,11 +567,15 @@ Meteor.methods({
|
|||||||
'createAdmin': function(userId) {
|
'createAdmin': function(userId) {
|
||||||
if (Roles.userIsInRole(Meteor.user()._id, ['superadmin'])) {
|
if (Roles.userIsInRole(Meteor.user()._id, ['superadmin'])) {
|
||||||
Roles.addUsersToRoles(userId, ['admin']);
|
Roles.addUsersToRoles(userId, ['admin']);
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'deleteAdmin': function(userId) {
|
'deleteAdmin': function(userId) {
|
||||||
if (Roles.userIsInRole(Meteor.user()._id, ['superadmin'])) {
|
if (Roles.userIsInRole(Meteor.user()._id, ['superadmin'])) {
|
||||||
Roles.removeUsersToRoles(userId, ['admin']);
|
Roles.removeUsersToRoles(userId, ['admin']);
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'createRequest': function(request) {
|
'createRequest': function(request) {
|
||||||
@ -563,11 +585,15 @@ Meteor.methods({
|
|||||||
request: request,
|
request: request,
|
||||||
timeRequested: new Date()
|
timeRequested: new Date()
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'deleteRequest': function(requestId) {
|
'deleteRequest': function(requestId) {
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||||
requests.remove({_id: requestId});
|
requests.remove({_id: requestId});
|
||||||
|
} else {
|
||||||
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user