我目前正在发布一个组中用户列表。虽然这个功能是可行的,但我无法阻止当前用户出现在列表中。如何删除当前用户?感谢任何建议和帮助。
路径:publish.js
Meteor.publish('studentList', function (group) {
if (Roles.userIsInRole(this.userId, ['teacher'], group)) {
return Meteor.users.find({roles:'student'}, {fields:{emails:1, profile: 1, roles: 1}});
} else {
// user not authorized. do not publish secrets
this.stop();
return;
}
});
路径:
studentList.js
Template.studentList.onCreated(function() {
var self = this;
self.autorun(function() {
self.subscribe('studentList')
});
});
Template.studentList.helpers({
studentList: ()=> {
return Meteor.users.find({});
},
});