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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0127a6ec9440aaa16e5ef5014695cf2e451ce1eba63f1bb19f69c0fa476db3d
4
- data.tar.gz: 3c3bf228895125edbc8388fea935b1db4a5a94b34fb59c1eeb037f3c4507ca91
3
+ metadata.gz: 59a393d33cfa210550260fe050c11b1eab54ff0b7f534391aad7bb2058a01ea0
4
+ data.tar.gz: 5edbfb9aa5538100895dc35e2fb4806a5915c730862d9e312f4900e858914b66
5
5
  SHA512:
6
- metadata.gz: b8bb650504894ad4f635453436a0a2f4a685169be4e7da2b3a0715b7d13e3da60b1d5a57eb35e271983fa96addc35f75d34f9384114ad42dd7290932a58c0a0b
7
- data.tar.gz: 850a9aa9c11faaaa176efb83aaa33e2728da4ae128b6d73ad1f1b818bf93735cdab814602f46b278f698fe63eff3b0868882bd1f6531144b7b33271e6947a87c
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.4.5'.freeze
2
+ VERSION = '2.4.7'.freeze
3
3
  end
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.5
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-10 00:00:00.000000000 Z
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