should fix #54
This commit is contained in:
parent
1533f24cda
commit
2b2a61dfe9
@ -35,30 +35,37 @@ Meteor.publish('classes', function() {
|
|||||||
return classes.find();
|
return classes.find();
|
||||||
} else {
|
} else {
|
||||||
// Return user classes (if private) and public classes.
|
// Return user classes (if private) and public classes.
|
||||||
return classes.find({
|
userclasses = Meteor.users.findOne(this.userId).profile.classes;
|
||||||
$or: [{
|
if (userclasses !== undefined) {
|
||||||
privacy: false
|
return classes.find({
|
||||||
|
$or: [{
|
||||||
|
privacy: false
|
||||||
|
}, {
|
||||||
|
_id: {
|
||||||
|
$in: Meteor.users.findOne(this.userId).profile.classes
|
||||||
|
}
|
||||||
|
}]
|
||||||
}, {
|
}, {
|
||||||
_id: {
|
// Return non-sensitive fields
|
||||||
$in: Meteor.users.findOne(this.userId).profile.classes
|
fields: {
|
||||||
|
school: 1,
|
||||||
|
name: 1,
|
||||||
|
hour: 1,
|
||||||
|
teacher: 1,
|
||||||
|
admin: 1,
|
||||||
|
status: 1,
|
||||||
|
privacy: 1,
|
||||||
|
category: 1,
|
||||||
|
moderators: 1,
|
||||||
|
banned: 1,
|
||||||
|
subscribers: 1
|
||||||
}
|
}
|
||||||
}]
|
});
|
||||||
}, {
|
} else {
|
||||||
// Return non-sensitive fields
|
return classes.find({
|
||||||
fields: {
|
_id: null
|
||||||
school: 1,
|
});
|
||||||
name: 1,
|
}
|
||||||
hour: 1,
|
|
||||||
teacher: 1,
|
|
||||||
admin: 1,
|
|
||||||
status: 1,
|
|
||||||
privacy: 1,
|
|
||||||
category: 1,
|
|
||||||
moderators: 1,
|
|
||||||
banned: 1,
|
|
||||||
subscribers: 1
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -80,7 +87,9 @@ Meteor.publish('requests', function() {
|
|||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return requests.find();
|
return requests.find();
|
||||||
} else {
|
} else {
|
||||||
return requests.find({requestor: this.userId});
|
return requests.find({
|
||||||
|
requestor: this.userId
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -482,6 +491,19 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'createProfile': function(userId) {
|
||||||
|
current = Meteor.users.findOne({
|
||||||
|
_id: userId
|
||||||
|
}).profile;
|
||||||
|
current.classes = [];
|
||||||
|
Meteor.users.update({
|
||||||
|
_id: userId
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
profile: current
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
'joinClass': function(input) {
|
'joinClass': function(input) {
|
||||||
var change = input[0];
|
var change = input[0];
|
||||||
var pass = input[1];
|
var pass = input[1];
|
||||||
@ -610,7 +632,9 @@ Meteor.methods({
|
|||||||
},
|
},
|
||||||
'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 {
|
} else {
|
||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user