effective_resources 2.4.5 → 2.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/app/controllers/concerns/effective/impersonation_controller/destroy.rb +25 -0
 - data/app/controllers/concerns/effective/impersonation_controller/impersonate.rb +29 -0
 - data/app/models/concerns/has_many_purgable.rb +2 -2
 - data/lib/effective_resources/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 59a393d33cfa210550260fe050c11b1eab54ff0b7f534391aad7bb2058a01ea0
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5edbfb9aa5538100895dc35e2fb4806a5915c730862d9e312f4900e858914b66
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bb45c37f2c5e2afef660925a218aceb7ee93f6ed7cc3e670c82e002edce9c9670e5a93604c677ea792999ecfa14ec93dfc25050de9ff0a66a151cf8ac9ebd568
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cd3e71440f3693dcb12278dea707273c974beff4dbd6801546d199d618dc731877f4487726a8c4519f4beb1d3492c727f693dc5d5b9a706dfee6dc2e214d6b88
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Effective
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ImpersonationController
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Destroy
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def destroy
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @user = current_user.class.find(session[:impersonation_user_id])
         
     | 
| 
      
 7 
     | 
    
         
            +
                    redirect_path = after_destroy_impersonate_path_for(@user)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    # Reset impersonation
         
     | 
| 
      
 10 
     | 
    
         
            +
                    session[:impersonation_user_id] = nil
         
     | 
| 
      
 11 
     | 
    
         
            +
                    session[:impersonation_original_path] = nil
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    expire_data_after_sign_in!
         
     | 
| 
      
 14 
     | 
    
         
            +
                    warden.session_serializer.store(@user, Devise::Mapping.find_scope!(@user))
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    redirect_to(redirect_path)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def after_destroy_impersonate_path_for(user)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    session[:impersonation_original_path].presence || '/admin/users'
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Effective
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ImpersonationController
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Impersonate
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def impersonate
         
     | 
| 
      
 6 
     | 
    
         
            +
                    @user = current_user.class.find(params[:id])
         
     | 
| 
      
 7 
     | 
    
         
            +
                    redirect_path = after_impersonate_path_for(@user)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    authorize! :impersonate, @user
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                    # Impersonate
         
     | 
| 
      
 12 
     | 
    
         
            +
                    session[:impersonation_user_id] = current_user.id
         
     | 
| 
      
 13 
     | 
    
         
            +
                    session[:impersonation_original_path] = request.referer.presence || '/admin/users'
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    expire_data_after_sign_in!
         
     | 
| 
      
 16 
     | 
    
         
            +
                    warden.session_serializer.store(@user, Devise::Mapping.find_scope!(@user))
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    @user.touch
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    redirect_to(redirect_path)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def after_impersonate_path_for(user)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    try(:dashboard_path) || try(:root_path) || '/'
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -71,7 +71,7 @@ module HasManyPurgable 
     | 
|
| 
       71 
71 
     | 
    
         | 
| 
       72 
72 
     | 
    
         
             
              def has_many_purgable_mark_for_destruction
         
     | 
| 
       73 
73 
     | 
    
         
             
                has_many_purgable_attachments.each do |name|
         
     | 
| 
       74 
     | 
    
         
            -
                  Array(public_send(name)).each { |attachment| attachment.mark_for_destruction }
         
     | 
| 
      
 74 
     | 
    
         
            +
                  Array(public_send(name)).each { |attachment| attachment.mark_for_destruction unless attachment.new_record? }
         
     | 
| 
       75 
75 
     | 
    
         
             
                end
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
       77 
77 
     | 
    
         
             
                true
         
     | 
| 
         @@ -80,7 +80,7 @@ module HasManyPurgable 
     | 
|
| 
       80 
80 
     | 
    
         
             
              def has_many_purgable_purge
         
     | 
| 
       81 
81 
     | 
    
         
             
                has_many_purgable_attachments.each do |name|
         
     | 
| 
       82 
82 
     | 
    
         
             
                  Rails.logger.info "[has_many_purgable] Purging #{name} attachments"
         
     | 
| 
       83 
     | 
    
         
            -
                  Array(public_send(name)).each { |attachment| attachment.purge }
         
     | 
| 
      
 83 
     | 
    
         
            +
                  Array(public_send(name)).each { |attachment| attachment.purge if attachment.marked_for_destruction? }
         
     | 
| 
       84 
84 
     | 
    
         
             
                end
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
                true
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: effective_resources
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.4.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Code and Effect
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-03-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -143,6 +143,8 @@ files: 
     | 
|
| 
       143 
143 
     | 
    
         
             
            - app/controllers/concerns/effective/crud_controller/save.rb
         
     | 
| 
       144 
144 
     | 
    
         
             
            - app/controllers/concerns/effective/crud_controller/submits.rb
         
     | 
| 
       145 
145 
     | 
    
         
             
            - app/controllers/concerns/effective/flash_messages.rb
         
     | 
| 
      
 146 
     | 
    
         
            +
            - app/controllers/concerns/effective/impersonation_controller/destroy.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - app/controllers/concerns/effective/impersonation_controller/impersonate.rb
         
     | 
| 
       146 
148 
     | 
    
         
             
            - app/controllers/concerns/effective/select2_ajax_controller.rb
         
     | 
| 
       147 
149 
     | 
    
         
             
            - app/controllers/concerns/effective/wizard_controller.rb
         
     | 
| 
       148 
150 
     | 
    
         
             
            - app/controllers/concerns/effective/wizard_controller/actions.rb
         
     |