createSchool() function

This commit is contained in:
yamanq 2016-08-10 07:54:25 -04:00
parent e43ceb74f5
commit 9610867f1c
2 changed files with 7 additions and 2 deletions

View File

@ -4,6 +4,7 @@ work = new Mongo.Collection("Work");
schools.schema = new SimpleSchema({ schools.schema = new SimpleSchema({
name: {type: String}, name: {type: String},
status: {type: Boolean},
aliases: {type: [String]} aliases: {type: [String]}
}); });

View File

@ -8,9 +8,13 @@ _uuid4 = function(cc) {
Meteor.methods({ Meteor.methods({
'genCode': function() { 'genCode': function() {
return 'xxxxxx'.replace(/[x]/g, _uuid4); return 'xxxxxx'.replace(/[x]/g, _uuid4);
}, },
//No Security 'createSchool': function(schoolname) {
if (Meteor.user() != null && schools.find({name:input.school}).fetch().length === 0) {
schools.insert({name: schoolname, status: false});
}
},
'createClass': function(input) { 'createClass': function(input) {
classes.schema.validate(input); classes.schema.validate(input);
if(Meteor.user() != null && classes.find({status:false, admin:Meteor.userId()}).fetch().length < 5 && if(Meteor.user() != null && classes.find({status:false, admin:Meteor.userId()}).fetch().length < 5 &&