Hi guys I am working to implement the roles of users I have 3 roles the administrator, free user and user premiun for the part of the role of administrator to get me to function perfectly the roles but when I want to perform the part of the user premiun and free user and I Step user _id it takes me as undefenied basically I have it as for administrator roles only that id does not take it.
When I click on my button I get this error Error invoking Method ‘toggleGetPremiun’: Match failed [400]
Testing by passing the id manually as a string by means of the meteortoys: allthings using ctrl + M I took your id and placed it like this and it works me Meteor.call (‘toggleGetPremiun’, ‘ygkjdkgglkldfgkldflfg’);
In the code I have this.
// server publish.js
Meteor.publish('user', function() {
return Meteor.users.find({});
});
// cliente getPremiun.js
Template.getPremiun.onCreated(function () {
var self = this;
self.autorun(function(){
Meteor.subscribe("user");
console.log(this._id); //I get undefined
});
});
Template.getPremiun.events({
"click #buttonGetPremiun": function(){
console.log(this._id); //I get undefined
Meteor.call('toggleGetPremiun', this._id);
}
});
// methods.js
Meteor.methods({
toggleGetPremiun(id) {
check(id, String);
console.log(id);
if (Roles.userIsInRole(id, 'Premiun')) {
Roles.removeUsersFromRoles(id, 'Premiun')
console.log("roles remove");
} else {
Roles.addUsersToRoles(id, 'Premiun')
console.log("roles add");
}
},
});