commenting on server
This commit is contained in:
parent
53b69348d1
commit
7b1219716e
@ -9,10 +9,11 @@ superadmins = [
|
|||||||
"ybq987@gmail.com",
|
"ybq987@gmail.com",
|
||||||
"ksjdragon@gmail.com"
|
"ksjdragon@gmail.com"
|
||||||
];
|
];
|
||||||
|
|
||||||
worktype = ["test", "quiz", "project", "normal", "other"];
|
worktype = ["test", "quiz", "project", "normal", "other"];
|
||||||
var possiblelist = ["moderators", "banned"];
|
var possiblelist = ["moderators", "banned"];
|
||||||
|
|
||||||
|
// Adds roles to superadmins
|
||||||
|
// Not necessary on every run
|
||||||
for (var i = 0; i < superadmins.length; i++) {
|
for (var i = 0; i < superadmins.length; i++) {
|
||||||
var superadmin = superadmins[i];
|
var superadmin = superadmins[i];
|
||||||
if (Meteor.users.findOne({
|
if (Meteor.users.findOne({
|
||||||
@ -33,6 +34,7 @@ Meteor.publish('classes', function() {
|
|||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return classes.find();
|
return classes.find();
|
||||||
} else {
|
} else {
|
||||||
|
// Return user classes (if private) and public classes.
|
||||||
return classes.find({
|
return classes.find({
|
||||||
$or: [{
|
$or: [{
|
||||||
privacy: false
|
privacy: false
|
||||||
@ -42,6 +44,7 @@ Meteor.publish('classes', function() {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
|
// Return non-sensitive fields
|
||||||
fields: {
|
fields: {
|
||||||
school: 1,
|
school: 1,
|
||||||
name: 1,
|
name: 1,
|
||||||
@ -64,6 +67,7 @@ Meteor.publish('work', function() {
|
|||||||
return work.find();
|
return work.find();
|
||||||
} else {
|
} else {
|
||||||
return work.find({
|
return work.find({
|
||||||
|
// Only return work of enrolled classes
|
||||||
class: {
|
class: {
|
||||||
$in: Meteor.users.findOne(this.userId).profile.classes
|
$in: Meteor.users.findOne(this.userId).profile.classes
|
||||||
}
|
}
|
||||||
@ -85,6 +89,7 @@ Meteor.publish('users', function() {
|
|||||||
return Meteor.users.find();
|
return Meteor.users.find();
|
||||||
} else {
|
} else {
|
||||||
return Meteor.users.find({}, {
|
return Meteor.users.find({}, {
|
||||||
|
// Only return necessary fields
|
||||||
fields: {
|
fields: {
|
||||||
'services.google.email': 1
|
'services.google.email': 1
|
||||||
}
|
}
|
||||||
@ -92,8 +97,10 @@ Meteor.publish('users', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Allows only superadmins to edit collections from client
|
||||||
Security.permit(['insert', 'update', 'remove']).collections([schools, classes, work]).ifHasRole('superadmin');
|
Security.permit(['insert', 'update', 'remove']).collections([schools, classes, work]).ifHasRole('superadmin');
|
||||||
|
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
'genCode': function() {
|
'genCode': function() {
|
||||||
currcode = Math.random().toString(36).substr(2, 6);
|
currcode = Math.random().toString(36).substr(2, 6);
|
||||||
@ -104,6 +111,8 @@ Meteor.methods({
|
|||||||
}
|
}
|
||||||
return currcode;
|
return currcode;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// School Functions
|
||||||
'createSchool': function(schoolname) {
|
'createSchool': function(schoolname) {
|
||||||
if (Meteor.user() !== null &&
|
if (Meteor.user() !== null &&
|
||||||
schools.findOne({
|
schools.findOne({
|
||||||
@ -137,6 +146,8 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Class Functions
|
||||||
'createClass': function(input) {
|
'createClass': function(input) {
|
||||||
classes.schema.validate(input);
|
classes.schema.validate(input);
|
||||||
if (Meteor.user() !== null &&
|
if (Meteor.user() !== null &&
|
||||||
@ -286,6 +297,8 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Work Functions
|
||||||
'createWork': function(input) {
|
'createWork': function(input) {
|
||||||
var ref = new Date();
|
var ref = new Date();
|
||||||
ref.setHours(0, 0, 0, 0);
|
ref.setHours(0, 0, 0, 0);
|
||||||
@ -434,6 +447,8 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// User Functions
|
||||||
'editProfile': function(change) {
|
'editProfile': function(change) {
|
||||||
var current = Meteor.user().profile;
|
var current = Meteor.user().profile;
|
||||||
current.school = change.school;
|
current.school = change.school;
|
||||||
@ -566,6 +581,8 @@ Meteor.methods({
|
|||||||
throw "Unauthorized";
|
throw "Unauthorized";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Admin Functions
|
||||||
'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']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user