diff --git a/firestore.rules b/firestore.rules index 7b263e1a..e42e3ed7 100644 --- a/firestore.rules +++ b/firestore.rules @@ -162,7 +162,7 @@ service cloud.firestore { match /groups/{groupId} { allow read; - allow update: if request.auth.uid == resource.data.creatorId + allow update: if (request.auth.uid == resource.data.creatorId || isAdmin()) && request.resource.data.diff(resource.data) .affectedKeys() .hasOnly(['name', 'about', 'contractIds', 'memberIds', 'anyoneCanJoin', 'aboutPostId' ]); @@ -183,11 +183,11 @@ service cloud.firestore { match /posts/{postId} { allow read; - allow update: if request.auth.uid == resource.data.creatorId + allow update: if isAdmin() || request.auth.uid == resource.data.creatorId && request.resource.data.diff(resource.data) .affectedKeys() .hasOnly(['name', 'content']); - allow delete: if request.auth.uid == resource.data.creatorId; + allow delete: if isAdmin() || request.auth.uid == resource.data.creatorId; } } } diff --git a/web/components/groups/group-about-post.tsx b/web/components/groups/group-about-post.tsx index 1b42c04d..ed5c20cc 100644 --- a/web/components/groups/group-about-post.tsx +++ b/web/components/groups/group-about-post.tsx @@ -1,4 +1,3 @@ -import { useAdmin } from 'web/hooks/use-admin' import { Row } from '../layout/row' import { Content } from '../editor' import { TextEditor, useTextEditor } from 'web/components/editor' @@ -16,20 +15,15 @@ import { usePost } from 'web/hooks/use-post' export function GroupAboutPost(props: { group: Group - isCreator: boolean + isEditable: boolean post: Post }) { - const { group, isCreator } = props + const { group, isEditable } = props const post = usePost(group.aboutPostId) ?? props.post - const isAdmin = useAdmin() - - if (group.aboutPostId == null && !isCreator) { - return
No post has been created
- } return (