meteor errors to fix #72

This commit is contained in:
Yaman Qalieh 2016-08-31 23:21:53 -04:00
parent 876272ada9
commit 7fc3a0b35c

View File

@ -156,7 +156,7 @@ Meteor.methods({
name: schoolname name: schoolname
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
// Deletes school // Deletes school
@ -166,7 +166,7 @@ Meteor.methods({
_id: schoolId _id: schoolId
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -198,7 +198,7 @@ Meteor.methods({
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
// For class admins to get code // For class admins to get code
@ -209,7 +209,7 @@ Meteor.methods({
if (foundclass && foundclass.admin == Meteor.userId()) { if (foundclass && foundclass.admin == Meteor.userId()) {
return foundclass.code; return foundclass.code;
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'changeAdmin': function(input) { 'changeAdmin': function(input) {
@ -235,7 +235,7 @@ Meteor.methods({
} }
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -271,7 +271,7 @@ Meteor.methods({
$set: set $set: set
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'deleteClass': function(classid) { 'deleteClass': function(classid) {
@ -298,7 +298,7 @@ Meteor.methods({
_id: classid _id: classid
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -327,7 +327,7 @@ Meteor.methods({
input.comments = []; input.comments = [];
work.insert(input); work.insert(input);
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -380,7 +380,7 @@ Meteor.methods({
}); });
} }
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'addComment': function(input) { 'addComment': function(input) {
@ -410,7 +410,7 @@ Meteor.methods({
} }
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -441,7 +441,7 @@ Meteor.methods({
$set: workobject $set: workobject
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'deleteWork': function(workId) { 'deleteWork': function(workId) {
@ -458,7 +458,7 @@ Meteor.methods({
_id: workId _id: workId
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -493,7 +493,7 @@ Meteor.methods({
}); });
return true; return true;
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'createProfile': function(userId) { 'createProfile': function(userId) {
@ -549,7 +549,7 @@ Meteor.methods({
}); });
return true; return true;
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'joinPrivateClass': function(input) { 'joinPrivateClass': function(input) {
@ -578,7 +578,7 @@ Meteor.methods({
}); });
return true; return true;
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'leaveClass': function(change) { 'leaveClass': function(change) {
@ -609,12 +609,12 @@ Meteor.methods({
}); });
return true; return true;
} else { } else {
throw "You are currently the admin of this class. Transfer ownership in order to leave this class."; throw new Meteor.Error("unauthorized", "You are currently the admin of this class. Transfer ownership in order to leave this class.");
} }
} }
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
@ -623,14 +623,14 @@ Meteor.methods({
if (Roles.userIsInRole(Meteor.user()._id, ['superadmin'])) { if (Roles.userIsInRole(Meteor.user()._id, ['superadmin'])) {
Roles.addUsersToRoles(userId, ['admin']); Roles.addUsersToRoles(userId, ['admin']);
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'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 { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'createRequest': function(request) { 'createRequest': function(request) {
@ -644,7 +644,7 @@ Meteor.methods({
timeRequested: new Date() timeRequested: new Date()
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
}, },
'deleteRequest': function(requestId) { 'deleteRequest': function(requestId) {
@ -653,7 +653,7 @@ Meteor.methods({
_id: requestId _id: requestId
}); });
} else { } else {
throw "Unauthorized"; throw new Meteor.Error("unauthorized", "You are not authorized to complete this action.");
} }
} }
}); });