# typed: ignore # Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.com/terms.html require 'sqreen/rules/rule_cb' require 'sqreen/actions' module Sqreen module Rules # Runs the block_user actions (for hooking Sqreen.{identify,auth_user}) class RunUserActions < CB def initialize(klass, method, auth_keys_idx) super(klass, method) @auth_keys_idx = auth_keys_idx end def post(_retval, _inst, args, _budget = nil) actions = actions_repo.get('block_user', args[@auth_keys_idx]) + actions_repo.get('redirect_user', args[@auth_keys_idx]) actions.each do |action| res = action.run args[@auth_keys_idx] return res unless res.nil? end nil end private # @return [Sqreen::Actions::Repository] def actions_repo Sqreen::Actions::Repository.current end end end end