Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从帐户ui meteor中删除用户_Meteor - Fatal编程技术网

如何从帐户ui meteor中删除用户

如何从帐户ui meteor中删除用户,meteor,Meteor,我正在制作一个meteor应用程序,使用帐户用户界面和引导等等,但我想知道是否有一种方法可以像管理员一样删除用户,因为最近人们一直在使用不合适的用户名等等..你可以像这样很容易地删除用户。让一个模板只受管理员帐户的保护,并在该模板上有一个用户列表,根据该列表创建一个类似这样的事件 Template.example.events({ 'click #deleteAccount':function(){ meteor.users.remove({_id:this._id}) } })

我正在制作一个meteor应用程序,使用帐户用户界面和引导等等,但我想知道是否有一种方法可以像管理员一样删除用户,因为最近人们一直在使用不合适的用户名等等..

你可以像这样很容易地删除用户。让一个模板只受
管理员帐户的保护
,并在该模板上有一个用户列表,根据该列表创建一个类似这样的事件

Template.example.events({
 'click #deleteAccount':function(){
    meteor.users.remove({_id:this._id}) 
  }
})
Meteor.allow({
 remove:function(){
   //if is admin return true;
  }
})
并使用这样的allow方法

Template.example.events({
 'click #deleteAccount':function(){
    meteor.users.remove({_id:this._id}) 
  }
})
Meteor.allow({
 remove:function(){
   //if is admin return true;
  }
})
但这不是一个好的做法,为什么?检查这个

如果有办法让我成为一名管理员

要以更好的方式完成此任务,请使用

有了它,您可以使用

{{if isInRole 'Admin'}}
 <!--show admin stuff-->
   {{else}}
 <!--sorry just admin stuff here -->
{{/else}}
试试看