mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 21:25:24 +08:00
DEV: Reuse code for TrustLevelAndStaffSetting (#15044)
The code that checked this permission was duplicated everytime a new settings of this type was added. This commit changes the behavior of some functionality because some feature checks were bypassed for staff members.
This commit is contained in:
@ -1021,6 +1021,12 @@ class User < ActiveRecord::Base
|
||||
admin? || moderator? || staged? || TrustLevel.compare(trust_level, level)
|
||||
end
|
||||
|
||||
def has_trust_level_or_staff?(level)
|
||||
return admin? if level.to_s == 'admin'
|
||||
return staff? if level.to_s == 'staff'
|
||||
has_trust_level?(level.to_i)
|
||||
end
|
||||
|
||||
# a touch faster than automatic
|
||||
def admin?
|
||||
admin
|
||||
|
Reference in New Issue
Block a user