Sha256: 8de6b0f31d356deaeb71a708586c2b847d787cac4010c44399c1e08243b65d07
Contents?: true
Size: 1012 Bytes
Versions: 6
Compression:
Stored size: 1012 Bytes
Contents
# frozen_string_literal: true require 'proxes/policies/request_policy' module ProxES class Request class BulkPolicy < RequestPolicy def post? return false if user.nil? patterns = Permission.for_user(user, 'INDEX').map do |permission| permission.pattern.gsub(/\{user.(.*)\}/) { |_match| user.send(Regexp.last_match[1].to_sym) } end return false if request.index && !index_allowed? return false if request.bulk_indices == '' || patterns.empty? patterns.find do |pattern| request.bulk_indices.find { |idx| idx !~ /#{pattern}/ } end.nil? end class Scope < RequestPolicy::Scope def resolve return false if user.nil? patterns = Permission.for_user(user, 'INDEX').map do |permission| permission.pattern.gsub(/\{user.(.*)\}/) { |_match| user.send(Regexp.last_match[1].to_sym) } end filter request.index, patterns end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems