Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 692ee2a

Browse files
authored
Fix inaccurate error message while trying to ban or unban a user with the same or higher PL (#16205)
1 parent 40901af commit 692ee2a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

changelog.d/16205.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix inaccurate error message while attempting to ban or unban a user with the same or higher PL by spliting the conditional statements. Contributed by @leviosacz.

synapse/event_auth.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,18 @@ def _is_membership_change_allowed(
669669
errcode=Codes.INSUFFICIENT_POWER,
670670
)
671671
elif Membership.BAN == membership:
672-
if user_level < ban_level or user_level <= target_level:
672+
if user_level < ban_level:
673673
raise UnstableSpecAuthError(
674674
403,
675675
"You don't have permission to ban",
676676
errcode=Codes.INSUFFICIENT_POWER,
677677
)
678+
elif user_level <= target_level:
679+
raise UnstableSpecAuthError(
680+
403,
681+
"You don't have permission to ban this user",
682+
errcode=Codes.INSUFFICIENT_POWER,
683+
)
678684
elif room_version.knock_join_rule and Membership.KNOCK == membership:
679685
if join_rule != JoinRules.KNOCK and (
680686
not room_version.knock_restricted_join_rule

0 commit comments

Comments
 (0)