check if code exists

This commit is contained in:
Yaman Qalieh 2016-08-18 19:08:58 -04:00
parent 5c3025363f
commit 24e44e1607

View File

@ -88,7 +88,11 @@ Security.permit(['insert', 'update', 'remove']).collections([schools, classes, w
Meteor.methods({
'genCode': function() {
return Math.random().toString(36).substr(2, 6);
currcode = Math.random().toString(36).substr(2, 6);
while (classes.findOne({code: currcode}) !== undefined) {
currcode = Math.random().toString(36).substr(2, 6);
}
return currcode;
},
'createSchool': function(schoolname) {
if (Meteor.user() !== null &&