devise_masquerade 1.3.6 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 289316079ab661599906ee251d276b9151b6d7b43a47131ea3683d4305cb198a
4
- data.tar.gz: fce111853661fbfe07cab2058aefa0ceb2bf1cd15830a3740dc9f293a2126a42
3
+ metadata.gz: 3f3c384ee31658834131c95ec34bc376340a9f7d8b7d237ed97316f6e61eb5ee
4
+ data.tar.gz: 78f66fc23c43a3db4eef66c98e15447decfea5627b2900c2ee827785a3b0cdd2
5
5
  SHA512:
6
- metadata.gz: 6d812afb79fc6e55780d5fff58432c6070bd23b5ec57d88d8706b1ee09eaf4a314bb68803a6924e731866594ba8cf4caeade6d6050c7ba888af6bebfc2058cd9
7
- data.tar.gz: f9002c0ba65f8a347f9ba3b4b2abc7aa363784e60c3b9c7e9d6071ca131fd5484c7aac664e7b5566030792243f093793702e6d26ee620117c8126bb3316f60b0
6
+ metadata.gz: a6b318f8d335a53524a94d24b5c1bc78c41bc308200a0eed543fabdfb891e63a1d119efee269282f9f2e4e1d1a7dd27161076ed9465c3ac55b188f2127dce429
7
+ data.tar.gz: 0d39bbd0099a4d70496ece49d3db3e955eadbcb14bc20accfcc9fcc90c070b9e7aa5b697ce91367c7d20590a218d182fe99b7d0c37b220fd4bbb59ee1f6c5bde
data/Gemfile.lock CHANGED
@@ -52,7 +52,7 @@ GIT
52
52
  PATH
53
53
  remote: .
54
54
  specs:
55
- devise_masquerade (1.3.6)
55
+ devise_masquerade (1.3.8)
56
56
  devise (>= 4.7.0)
57
57
  globalid (>= 0.3.6)
58
58
  railties (>= 5.2.0)
@@ -10,41 +10,52 @@ class Devise::MasqueradesController < DeviseController
10
10
  prepend_before_action :masquerade_authorize!
11
11
 
12
12
  def show
13
- masqueradable_resource = find_masqueradable_resource
13
+ if send("#{masqueraded_resource_name}_masquerade?")
14
+ resource = send("current_#{masquerading_resource_name}")
14
15
 
15
- save_masquerade_owner_session(masqueradable_resource)
16
+ go_back(resource, path: after_masquerade_full_path_for(resource))
17
+ else
18
+ masqueradable_resource = find_masqueradable_resource
16
19
 
17
- self.resource = masqueradable_resource
18
- sign_out(send("current_#{masquerading_resource_name}"))
20
+ save_masquerade_owner_session(masqueradable_resource)
19
21
 
20
- unless resource
21
- flash[:error] = "#{masqueraded_resource_class} not found."
22
- redirect_to(new_user_session_path) and return
23
- end
22
+ resource = masqueradable_resource
23
+ sign_out(send("current_#{masquerading_resource_name}"))
24
24
 
25
- request.env['devise.skip_trackable'] = '1'
25
+ unless resource
26
+ flash[:error] = "#{masqueraded_resource_class} not found."
27
+ redirect_to(new_user_session_path) and return
28
+ end
26
29
 
27
- masquerade_sign_in(resource)
30
+ request.env['devise.skip_trackable'] = '1'
28
31
 
29
- go_back(resource, path: after_masquerade_full_path_for(resource))
32
+ masquerade_sign_in(resource)
33
+
34
+ go_back(resource, path: after_masquerade_full_path_for(resource))
35
+ end
30
36
  end
31
37
 
32
38
  def back
33
- masqueradable_resource = send("current_#{masqueraded_resource_name}")
39
+ unless send("#{masqueraded_resource_name}_masquerade?")
40
+ resource = send("current_#{masqueraded_resource_name}")
41
+ go_back(resource, path: after_back_masquerade_path_for(resource))
42
+ else
43
+ masqueradable_resource = send("current_#{masqueraded_resource_name}")
34
44
 
35
- unless send("#{masqueraded_resource_name}_signed_in?")
36
- head(401) and return
37
- end
45
+ unless send("#{masqueraded_resource_name}_signed_in?")
46
+ head(401) and return
47
+ end
38
48
 
39
- self.resource = find_owner_resource(masqueradable_resource)
40
- sign_out(send("current_#{masqueraded_resource_name}"))
49
+ resource = find_owner_resource(masqueradable_resource)
50
+ sign_out(send("current_#{masqueraded_resource_name}"))
41
51
 
42
- masquerade_sign_in(resource)
43
- request.env['devise.skip_trackable'] = nil
52
+ sign_in(resource)
53
+ request.env['devise.skip_trackable'] = nil
44
54
 
45
- go_back(resource, path: after_back_masquerade_path_for(resource))
55
+ go_back(resource, path: after_back_masquerade_path_for(resource))
46
56
 
47
- cleanup_masquerade_owner_session(masqueradable_resource)
57
+ cleanup_masquerade_owner_session(masqueradable_resource)
58
+ end
48
59
  end
49
60
 
50
61
  protected
@@ -50,7 +50,8 @@ module DeviseMasquerade
50
50
  return unless send(:#{name}_masquerade?)
51
51
 
52
52
  key = "devise_masquerade_#{name}_" + current_#{name}.to_param
53
- GlobalID::Locator.locate_signed(::Rails.cache.read(key.to_sym, for: 'masquerade'))
53
+ sgid = ::Rails.cache.read(key.to_sym)
54
+ GlobalID::Locator.locate_signed(sgid, for: 'masquerade')
54
55
  end
55
56
 
56
57
  private
@@ -1,3 +1,3 @@
1
1
  module DeviseMasquerade
2
- VERSION = '1.3.6'.freeze
2
+ VERSION = '1.3.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_masquerade
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Korsak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-19 00:00:00.000000000 Z
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler