Skip to content

Commit f30c2c2

Browse files
authored
Merge pull request #5024 from rtibbles/consistent_perms_checking
Fixes oversight in channel permissions in internal endpoints which blocks admin users unintentionally
2 parents 72cb45c + 5e36bba commit f30c2c2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

contentcuration/contentcuration/views/internal.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,13 @@ def create_channel(channel_data, user):
471471
# Set up initial channel
472472
channel, isNew = Channel.objects.get_or_create(id=channel_data["id"], actor_id=user.id)
473473

474-
# Add user as editor if channel is new or channel has no editors
475-
# Otherwise, check if user is an editor
476-
if isNew or channel.editors.count() == 0:
474+
# Add user as editor if channel is new
475+
if isNew:
477476
channel.editors.add(user)
478-
elif user not in channel.editors.all():
477+
try:
478+
# Check if user is an editor
479+
channel = Channel.get_editable(user, channel.id)
480+
except Channel.DoesNotExist:
479481
raise SuspiciousOperation("User is not authorized to edit this channel")
480482

481483
extra_fields = channel_data.get('extra_fields') or {}

0 commit comments

Comments
 (0)