joinClass fix

This commit is contained in:
Yaman Qalieh 2016-08-12 15:50:07 -04:00
parent 09104bbbeb
commit 92c3229538

View File

@ -148,17 +148,18 @@ Meteor.methods({
change = input[0]; change = input[0];
pass = input[1]; pass = input[1];
if (Meteor.user().profile.classes === undefined) {
curr = Meteor.user().profile; // if (Meteor.user().profile.classes === undefined) {
curr.classes = []; // curr = Meteor.user().profile;
Meteor.users.update({ // curr.classes = [];
_id: Meteor.userId() // Meteor.users.update({
}, { // _id: Meteor.userId()
$set: { // }, {
profile: curr // $set: {
} // profile: curr
}); // }
} // });
// }
prof = Meteor.user().profile; prof = Meteor.user().profile;
found = classes.findOne({ found = classes.findOne({
_id: change, _id: change,
@ -167,11 +168,11 @@ Meteor.methods({
if (Meteor.user() !== null && if (Meteor.user() !== null &&
found !== null && found !== null &&
pass === found.code && pass === found.code &&
!found.banned.includes(Meteor.userId()) && found.banned.indexOf(Meteor.userId()) === -1 &&
!prof.classes.includes(change)) { prof.classes.indexOf(change) === -1) {
current = Meteor.user().profile; current = Meteor.user().profile;
current.classes.append(change); current.classes.push(change);
Meteor.users.update({ Meteor.users.update({
_id: Meteor.userId() _id: Meteor.userId()
}, { }, {