2016-01-22 59 views
1

我正在寻找具有用户权限管理和查看应用程序内容访问权限的解决方案。用户在流星中的新网站应用程序的访问管理

我的目标是:

  • 观点不同的网页登录不同的用户组
  • 我需要通过管理员帐户来管理这个群体
  • 那么Web应用程序会检查用户的权利,并准备专门的页面每个组

我花了一些时间,但无法找到该解决方案的好模块。并决定创建我自己的管理面板,以及包含用户权限的集合。

在这一刻我有一个快速的形式的问题,它并没有告诉我一个值的一半:

Meteor.publish('allUsers',function(){ 
    return Meteor.users.find({}) 
}); 
Meteor.publish('userAcCardS',function(){ 
    return RoleCard.find({userId: this.userId}); 
}); 

<template name="singleUser"> 
    <h1 class="page-title"> user - {{_id}} <i class="fa fa-pencil"></i></h1> 
    <h3> 
    -{{RCList._id}}-{{RCList.name}}-{{RCList.isAdmin}}- 

    {{#if RCList}} 
    {{> quickForm id="update_card" collection="RoleCard" doc=this type="update"}} 
    {{else}} 
    noth {{> quickForm id="new_card" collection="RoleCard" type="insert"}} 
    {{/if}} 
    </h3> 
</template> 

Template.singleUser.onCreated(function() { 
    var self = this; 
    self.autorun(function() { 
    self.subscribe('userAcCardS'); 
    }); 
}); 

Template.singleUser.helpers({ 
    userEmail: function(){ 
    return this.emails\[0\].address; 
    }, 
    RCList: function(){ 
     return RoleCard.findOne({userId: this._id}); 
    } 
}); 

但我只看到这一点:

User Management Meteor

那么,什么是错的?如果你知道它,也许你可以给我建议,以使用另一种解决方案,如流星包?

或者,也许你可以告诉我如何渲染基于“RCList”的autoform,可以提供角色卡集合的更改,如果可能的话?我是流星和js中的崭新...

回答

0

最受欢迎的角色包是alanning:roles包。它允许您控制用户角色并根据这些角色限制访问。使用此命令来安装它为您的项目:

流星添加alanning:角色

这里是它的一个例子是使用限制公布的数据:

Meteor.publish('secrets', function (group) { 
    if (Roles.userIsInRole(this.userId, ['view-secrets','admin'], group)) { 
     return Meteor.secrets.find({group: group}); 
    } else { 
     // user not authorized. do not publish secrets 
     this.stop(); 
     return; 
    } 
}); 

限制所看到的示例客户:

<template name="header"> 
    ... regular header stuff 
    {{#if isInRole 'admin'}} 
     {{> admin_nav}} 
    {{/if}} 
    {{#if isInRole 'admin,editor'}} 
     {{> editor_stuff}} 
    {{/if}} 
</template> 
相关问题