Skip to content

Commit fc206f4

Browse files
authored
Restrict custom view updates/deletions to owner (#1751)
1 parent aa5993c commit fc206f4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

backend/src/database/repositories/customViewRepository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class CustomViewRepository {
6363
throw new Error404()
6464
}
6565

66+
// don't allow other users private custom views to be updated
67+
if (record.visibility === 'user' && record.createdById !== currentUser.id) {
68+
throw new Error('Update not allowed as custom view was not created by user!')
69+
}
70+
6671
// we don't allow placement to be updated
6772
record = await record.update(
6873
{
@@ -112,6 +117,11 @@ class CustomViewRepository {
112117
throw new Error404()
113118
}
114119

120+
// don't allow other users private custom views to be deleted
121+
if (record.visibility === 'user' && record.createdById !== currentUser.id) {
122+
throw new Error('Deletion not allowed as custom view was not created by user!')
123+
}
124+
115125
// update who deleted the custom view
116126
await record.update(
117127
{

0 commit comments

Comments
 (0)