Skip to content

Commit f63f929

Browse files
authored
Fix delete auth check for posts delete (#3312)
Assume the post object is all that is needed to check permissions. This is because we know we want the creator to be able to delete. Previously other members could delete any post - this seems like a mistake. So this new code prevents that by not having the member context. This kinda breaks the isolation I wanted these to have from policies. I wanted policies to be in full control of the permissions. But we have to provide the right context/attributes. The project doesn't have the creator attribute (or even the right one). We could do a better job exposing exactly what attributes are given to the privileges service instead of the dto object wholesale. The policies are also ill-equipped to declare permissions for these "embedded" resources. A rewrite is needed there.
1 parent 5dbb1f2 commit f63f929

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/components/post/post.service.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ export class PostService {
7676
async delete(id: ID, session: Session): Promise<void> {
7777
const object = await this.repo.readOne(id, session);
7878

79-
const perms = await this.getPermissionsFromPostable(
80-
object.parent.properties.id,
81-
session,
82-
);
83-
perms.verifyCan('delete');
79+
this.privileges.for(session, Post, object).verifyCan('delete');
8480

8581
try {
8682
await this.repo.deleteNode(object);

0 commit comments

Comments
 (0)