Meteor 只向客户端发送授权模板 [英] Meteor send only authorized templates down to the client

查看:50
本文介绍了Meteor 只向客户端发送授权模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道meteor 会将模板编译到客户端.使用meteor-auth系统,是否有一种方法仅在用户有权查看模板时才发送模板(因此在客户端检查html代码时它们不可见)?例如,我们不想总是将管理部分发送到浏览器.

I know meteor kind of compiles the templates up down to the client. With the meteor-auth system is there a way of only sending down templates when the user has permissions to see them (so they're not visible when inspecting html code on the client end)? For example we don't want to always send down an admin section down to the browser.

例如如果我有

<template name="admin_main">
    <h2>Admin Menu</h2>
    ....
</template>

如果我的 Meteor.user().profile.userlevel5,那么我才希望将模板发布给用户.否则我的其他用户可以通过一些 js 知识看到我的管理菜单

If my Meteor.user().profile.userlevel is 5, only then I'd like the template to be published to the user. Otherwise the rest of my users can see my admin menu with a bit of js knowledge

推荐答案

我不相信这是可能的.

对于管理部分,您可以创建两个单独的应用程序,并让它们通过同一个 DDP 服务器进行通信.然而,这会使共享代码变得更加困难.

For an Admin section, you could create two separate apps and have them communicate through the same DDP server. This would make sharing code more difficult, however.

DDP 可以与任何数据库、框架或编程语言一起工作,并且可以在服务器、客户端和移动设备上工作.实际上,您可以调用 Meteor.connect 连接到任何 DDP 服务器——例如其他人编写的 Meteor 应用程序!-- 并对其发布的任何数据进行实时订阅.

DDP can work with any database, framework, or programming language, and it can work on servers, clients, and mobile devices. In fact, you can call Meteor.connect to connect to any DDP server -- such as a Meteor app written by someone else! -- and make realtime subscriptions to any data it's publishing.

http://meteor.com/blog/2012/03/21/介绍-ddp

这篇关于Meteor 只向客户端发送授权模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆