forgeplus/app/constraint/admin_constraint.rb

8 lines
310 B
Ruby
Raw Normal View History

2020-03-09 00:40:16 +08:00
class AdminConstraint
def matches?(request)
laboratory = Laboratory.first
return false unless request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"]
user = User.find request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"]
user && user.admin?
end
end