【发布时间】:2017-06-15 14:38:18
【问题描述】:
我试图仅向某些用户显示 dom-if 模板,但我不知道该怎么做。这是我正在尝试做的伪代码:
<template is="dom-if" if="{{user.isAdmin}}" restamp="true">
<hr />
<h1>Add new conference:</h1>
<paper-input
id="title"
label="Título"
type="text"
name="title">
</paper-input>
<paper-fab id="saveFab" icon="cloud-upload" on-tap="add"></paper-fab>
</template>
<script>
Polymer({
is: 'my-conferences',
properties: {
data: Array,
user: Object,
},
...
其中“用户”是我从<firebase-auth> 元素中获得的对象。像 user.isAdmin 这样的东西是我想要实现的。
有什么想法吗?谢谢!
【问题讨论】:
-
您能发布一个完整的代码示例吗?目前,对于您的
my-conferences元素,我没有看到任何dom-module。如果你没有它,那么这就是你的问题。如果您确实有它,那么问题出在其他地方,我们需要查看更多代码才能对其进行分析。 -
我有默认的聚合物元素结构(包括 dom-module)。这里所有的源代码:github.com/zolastro/HackersWeekMalaga/blob/master/src/my-app/…
-
您如何验证您的管理员身份?您对 firebase 使用哪种身份验证类型?也许看看这里:stackoverflow.com/questions/17607101/…
-
我使用“google”作为帐户提供商。这个想法是允许这些谷歌帐户之一成为管理员。不过,我会尝试使用
firebaseRef.authWithCustomToken。 -
您是否有幸创建了管理员帐户?
标签: authentication firebase polymer firebase-authentication dom-if