0
誰もが投稿を閲覧できるシンプルなブログのウェブサイトがありますが、管理者だけが編集できます。私はエラーError: Missing or insufficient permissions.
ブログのウェブサイトのFirestoreのルール
{
email:"[email protected]"
},
{
email:"[email protected]"
}
マイクラウドFirestoreルール
service cloud.firestore {
match /databases/{database}/documents {
match /posts/{post} {
allow read;
allow write: if get(/databases/$(database)/documents/admins/$(admin)).data.email == request.auth.token.email;
}
}
}
を:コレクション文書がどのように見えるの管理者に
{
title:"Hello World",
body:"Hello Brian"
},
{
title:"Gumdrops",
body:"Goody, goody gumdrops"
},
:
ポスト収集文書は次のようになり私はAngularFire2を使用していたクライアント側で
は、そのための私のコードはそうなります。私は間違って何をやっている
import { Component } from '@angular/core';
import { AuthService } from '../auth/auth.service';
import { AngularFirestore, AngularFirestoreCollection } from 'angularfire2/firestore';
export interface Post {
id?: string;
title: string;
body: string;
}
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent {
private postsCollection: AngularFirestoreCollection<Post>;
public posts:any;
constructor(
private afs: AngularFirestore,
public authService: AuthService
) {
this.postsCollection = afs.collection<Post>('posts');
this.posts = this.postsCollection.snapshotChanges().map(actions => {
return actions.map(a => {
const data = a.payload.doc.data() as Post;
data.id = a.payload.doc.id;
return data;
});
});
}
addPost(post) {
this.postsCollection.add(post).then((ret) => {
console.log('post added');
}, (error) => {
console.log(error);
});
}
?
質問を編集して、そのエラーを発生させるコードを表示できますか? –
私は読書に問題はなく、私のルールを「書き込み許可」に変更すると、それも機能します。 –
あなたは 'プッシュキー'を管理者のキーとして使用していますか? – Hareesh