Server bug fixes
This commit is contained in:
parent
b9d22b9958
commit
379f903507
@ -94,7 +94,7 @@ Meteor.methods({
|
||||
'createSchool': function(schoolname) {
|
||||
if (Meteor.user() !== null &&
|
||||
schools.findOne({
|
||||
name: input.school
|
||||
name: schoolname
|
||||
}) !== null &&
|
||||
schools.findOne({
|
||||
status: false,
|
||||
@ -135,7 +135,7 @@ Meteor.methods({
|
||||
} else {
|
||||
input.status = false;
|
||||
}
|
||||
input.subscribers = [Meteor.userId()];
|
||||
input.subscribers = [];
|
||||
input.admin = Meteor.userId();
|
||||
if (input.privacy) {
|
||||
Meteor.call('genCode', function(error, result) {
|
||||
@ -149,8 +149,11 @@ Meteor.methods({
|
||||
}
|
||||
input.moderators = [];
|
||||
input.banned = [];
|
||||
classes.insert(input);
|
||||
Meteor.call('joinClass', classes.findOne(input)._id, input.code, function(error, result) {});
|
||||
|
||||
classes.insert(input, function(err, result) {
|
||||
Meteor.call('joinClass', [result, input.code]);
|
||||
});
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
throw "Unauthorized";
|
||||
@ -203,9 +206,12 @@ Meteor.methods({
|
||||
var found = classes.findOne({
|
||||
_id: classid
|
||||
});
|
||||
if (Meteor.user() !== null && found !== null && (found.admin === Meteor.user()._id || Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']))) {
|
||||
if (Meteor.user() !== null && found !== null &&
|
||||
(found.admin === Meteor.user()._id || Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']))) {
|
||||
for (var i = 0; i < found.subscribers.length; i++) {
|
||||
profile.classes.splice(index, 1);
|
||||
var current = Meteor.users.findOne({_id:found.subscribers[i]}).profile;
|
||||
var index = current.classes.indexOf(classid);
|
||||
current.classes.splice(index, 1);
|
||||
Meteor.users.update({
|
||||
_id: found.subscribers[i]
|
||||
}, {
|
||||
@ -240,7 +246,6 @@ Meteor.methods({
|
||||
input.done = [];
|
||||
input.numberdone = 0;
|
||||
input.comments = [];
|
||||
console.log(input);
|
||||
work.insert(input);
|
||||
}
|
||||
|
||||
@ -251,7 +256,7 @@ Meteor.methods({
|
||||
var currentclass = classes.findOne({
|
||||
_id: work.findOne({
|
||||
_id: change._id
|
||||
}).class
|
||||
})["class"]
|
||||
});
|
||||
var authorized = currentclass.moderators.concat(currentclass.admin);
|
||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||
@ -326,7 +331,8 @@ Meteor.methods({
|
||||
var currentclass = classes.findOne({
|
||||
_id: workobject.class
|
||||
});
|
||||
if (currentclass.subscribers.indexOf(Meteor.userId()) != -1 && ["confirmations", "reports", "done"].indexOf(input[1]) != -1) {
|
||||
if (currentclass.subscribers.indexOf(Meteor.userId()) != -1 &&
|
||||
["confirmations", "reports", "done"].indexOf(input[1]) != -1) {
|
||||
userindex = workobject[input[1]].indexOf(Meteor.userId());
|
||||
if (userindex === -1) {
|
||||
workobject[input[1]] = workobject[input[1]].concat(Meteor.userId());
|
||||
@ -344,7 +350,7 @@ Meteor.methods({
|
||||
var currentclass = classes.findOne({
|
||||
_id: work.findOne({
|
||||
_id: workId
|
||||
}).class
|
||||
})["class"]
|
||||
});
|
||||
var authorized = currentclass.moderators.concat(currentclass.admin);
|
||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||
@ -402,7 +408,7 @@ Meteor.methods({
|
||||
prof.classes.indexOf(change) === -1) {
|
||||
classes.update({_id: found._id}, {$set: {subscribers: found.subscribers.concat(Meteor.userId())}});
|
||||
var current = Meteor.user().profile;
|
||||
current.classes.concat(change);
|
||||
current.classes = current.classes.concat(change);
|
||||
Meteor.users.update({
|
||||
_id: Meteor.userId()
|
||||
}, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user