2017-12-21 10 views
2

suspendedProfileという名前の読み取り専用プロパティを、userドキュメントに、現在ログインしているユーザーの読み取り/書き込みアクセス権を持つ他のすべてのプロパティと共に使用したいと考えています。単純なセキュリティルールでそれを行う方法はありますか?クラウドFirestoreのセキュリティルール - ドキュメント内の単一の保護フィールド

私は約2ソリューションと思った:

  1. 不許可は、それがallow write: if request.resource.data.suspendedProfile == null;
  2. のように、私は最初のオプションは、すべての方が良いと思いますuser文書

内部allow read;/secureコレクションをプロパティを変更書き込みユーザー関連のプロパティは単一のドキュメントになっていますが、私はあなたの考えを聞いて欲しいです。これを達成する他の簡単な方法はありますか?

答えて

3

私自身の答えであるusing Firebase documentationの解決策を見つけることができたと思います。

// A user can update a product reviews, but they can't change 
// the headline. 
// Also, they should only be able up update their own product review, 
// and they still have to list themselves as an author 
allow update: if request.resource.data.headline == resource.data.headline 
        && resource.data.authorID == request.auth.userID 
        && request.resource.data.authorID == request.auth.userID; 

だから、私の場合、私はちょうどallow update: if request.resource.data.suspendedProfile == resource.data.suspendedProfile

ます
関連する問題