Skip to content

Commit

Permalink
Only check if user has moderator role in is_moderator? method
Browse files Browse the repository at this point in the history
In the beginning of the content_moderation feature we considered
user that have the admin or stuff roles to be moderator. But now
we have the dedicated moderator role. So we only should check
for that in the `is_moderator?` method and leave the rest to
the pundit policies.
  • Loading branch information
krauselukas authored and danidoni committed Oct 2, 2023
1 parent a79fd68 commit bdf2dec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def is_nobody?
end

def is_moderator?
is_admin? || is_staff?
roles.exists?(title: 'Moderator')
end

def is_active?
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/policies/decision_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class DecisionPolicy < ApplicationPolicy
def create?
return false unless Flipper.enabled?(:content_moderation, user)

user.is_admin? || user.is_moderator?
user.is_moderator? || user.is_admin? || user.is_staff?
end
end

0 comments on commit bdf2dec

Please sign in to comment.