fix: Namespace.moderators returned all members; owners now imply mod
moderators property returned self.enabled_users (every enabled member), so every user who had ever posted got moderator powers: spam approve/deny, edit/delete other users' comments, moderator Slack notifications. Bug was universal across all namespaces — any site where users post was affected. Fix: moderators now returns only users with role='moderator'. Owners now implicitly pass is_moderator() checks, since NamespaceUser is single-role per user per namespace; this keeps owners functional without needing a data migration.
This commit is contained in:
parent
e1952cb1c4
commit
a5c3e36fce
1 changed files with 4 additions and 1 deletions
|
|
@ -272,7 +272,7 @@ class Namespace(RBase, Base):
|
|||
@property
|
||||
def moderators(self):
|
||||
"""Return a list of moderator role User objects."""
|
||||
return self.enabled_users
|
||||
return self.roles.get("moderator", [])
|
||||
|
||||
@property
|
||||
def visible_roots(self):
|
||||
|
|
@ -382,12 +382,15 @@ class Namespace(RBase, Base):
|
|||
"""Return True if given user moderates this namespace, else False.
|
||||
|
||||
Superusers are treated as moderators on every namespace.
|
||||
Owners are implicitly moderators.
|
||||
"""
|
||||
if user and user.authenticated:
|
||||
if getattr(user, "is_superuser", False):
|
||||
return True
|
||||
if user in self.moderators:
|
||||
return True
|
||||
if user in self.owners:
|
||||
return True
|
||||
return False
|
||||
|
||||
def can_alter_node(self, node, user):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue