Sha256: 5bcf498abf410568bc940610fc610cb74e85d0f8a412cd3a63c29e65b8c4049f
Contents?: true
Size: 362 Bytes
Versions: 3
Compression:
Stored size: 362 Bytes
Contents
module Panda module CMS class AdminConstraint def initialize(&block) @block = block end def matches?(request) user = current_user(request) user.present? && user.admin? && @block&.call(user) end def current_user(request) User.find_by(id: request.session[:user_id]) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
panda-cms-0.7.3 | app/constraints/panda/cms/admin_constraint.rb |
panda-cms-0.7.2 | app/constraints/panda/cms/admin_constraint.rb |
panda-cms-0.7.0 | app/constraints/panda/cms/admin_constraint.rb |