【发布时间】:2020-10-15 12:27:38
【问题描述】:
我希望用户只能看到他自己的帖子,并且没有人应该访问他的帖子。 Auth + 发布已经可以并且正在工作。但没有 Firebase 限制。
对于 firebase,我计划使用此规则。可以吗?
{
"rules": {
"notes": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null"
}
}
}
}
将请求放入角度:
this.http
.put(
'https://_____.firebaseio.com/notes.json?auth=<ID_TOKEN>',
notes
)
以角度获取请求(此处为完整函数)
loadNotes() {
return this.http
.get<Note[]>(
'https://______.firebaseio.com/notes.json?auth=<ID_TOKEN>'
)
.pipe(
map(notes => {
return notes.map(note => {
return {
...note
};
});
}),
tap(notes => {
this.noteService.setNotes(notes);
})
);
}
}
我认为这里最关键的点是指向 firebase 数据库和 firebase 规则的链接。
我真的很感激一些帮助!谢谢。
【问题讨论】:
标签: angular typescript firebase