2017-12-21 6 views
2

user 문서에 suspendedProfile이라는 읽기 전용 속성을 갖고 싶습니다. 다른 모든 속성은 현재 로그인 한 사용자에 대해 읽기/쓰기 권한이 있습니다. 간단한 보안 규칙으로이를 수행 할 수있는 방법이 있습니까?Cloud Firestore 보안 규칙 - 문서의 단일 보호 필드

  1. 해제하면 그가 user 문서 내부 allow read;/secure 컬렉션

내가 첫 번째 옵션은 더 나은 모든 생각 allow write: if request.resource.data.suspendedProfile == null;

  • 같은 속성을 수정 기록 :

    나는 약 2 솔루션을 생각 사용자 관련 속성은 단일 문서에 있지만 생각을 듣고 싶습니다. 이것을 달성하는 다른 간단한 방법이 있습니까?

  • 답변

    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

    관련 문제