leaveClass function
This commit is contained in:
parent
62287f3f22
commit
f67af27300
@ -52,7 +52,7 @@ Meteor.methods({
|
||||
},
|
||||
'joinClass': function(change, pass) {
|
||||
found = classes.find({_id: change, status: true}).fetch();
|
||||
if (Meteor.user() != null && found.length > 0 && pass === found[0].code) {
|
||||
if (Meteor.user() != null && found.length > 0 && pass === found[0].code && Meteor.user().profile.classes.indexOf(change) === -1) {
|
||||
current = Meteor.user().profile;
|
||||
current.classes.append(change);
|
||||
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
|
||||
@ -60,5 +60,17 @@ Meteor.methods({
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
'leaveClass': function(change) {
|
||||
if (Meteor.user() != null) {
|
||||
profile = Meteor.user().profile
|
||||
index = profile.classes.indexOf(change)
|
||||
if (index >= 0) {
|
||||
profile.classes.splice(index, 1);
|
||||
Meteor.users.update({_id: Meteor.userId()}, {$set: {profile: current}});
|
||||
return 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user