Skip to content

Commit

Permalink
Users: Update promotion code.
Browse files Browse the repository at this point in the history
  • Loading branch information
nottalulah committed Sep 12, 2023
1 parent de669cf commit 3cb2b29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/logical/user_promotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def create_mod_actions
end

def validate!
return if promoter.is_owner?

if !promoter.is_moderator?
raise User::PrivilegeError, "You can't promote or demote other users"
elsif promoter == user
Expand All @@ -48,8 +50,6 @@ def validate!
raise User::PrivilegeError, "You can't promote other users to your rank or above"
elsif user.level >= promoter.level
raise User::PrivilegeError, "You can't promote or demote other users at your rank or above"
elsif !(promoter.is_owner? || promoter == User.system) && (new_level > User::Levels::CONTRIBUTOR || user.level > User::Levels::CONTRIBUTOR)
raise User::PrivilegeError, "You can't promote or demote users to that level"
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/policies/user_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def destroy?
end

def promote?
(user.is_owner? || (user.is_moderator? && record.level < User::Levels::APPROVER)) && user != record
user.is_moderator?
end

def fix_counts?
Expand Down

0 comments on commit 3cb2b29

Please sign in to comment.