devise_masquerade 1.3.1 → 1.3.3

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: 7e8cd4d05e6a1c75e17d26588532e261c01e95689d87d491757132d3242faed7
4
- data.tar.gz: a9e581005ebf3f238f39aa83d276cef37716bbc1669462f2a4e80f745e29c70a
3
+ metadata.gz: 23f626ba1c590f1686660a00804eaa5c5139a210fae80e72168a9f0a322e4be8
4
+ data.tar.gz: ee1641f8fed338ac83be5935b5e374df60fc7eb003919c120b24052528462302
5
5
  SHA512:
6
- metadata.gz: 27aee8dd6cfd3f270a466bc30c4a4b545c7b4e944c3794567ed6c220b86598ff2e5361cb00a7cb7a49d20fccc6532cbd97cd0e301459c5b980bbe2e6052847d8
7
- data.tar.gz: 4df45047b964dd10855dbf563f907bedd5e497130cfab4e5b7d65168d5ca91d47265ea562aea1345563fe15b17f7e944b867dfae3420f4e9cbd030287952bc8f
6
+ metadata.gz: 49c892cf2302d56d3d3aafb106d4e2eeba92b6c2f256440aa27a428df620bd16f49e89d5666ef6c2083e44fb260c1cb0beef3e575234cf5c6e91bff8f621dc4d
7
+ data.tar.gz: 357d959e456fa0d10a748f2c15b4cd0f94f8c21e773c970d52715e752dfd29c4d39f1e5f06fb2cbe11c8b4517c9503203954af1674a4a02c89669ffacbacc5c0
data/Gemfile.lock CHANGED
@@ -52,7 +52,7 @@ GIT
52
52
  PATH
53
53
  remote: .
54
54
  specs:
55
- devise_masquerade (1.3.1)
55
+ devise_masquerade (1.3.3)
56
56
  devise (>= 4.7.0)
57
57
  globalid (>= 0.3.6)
58
58
  railties (>= 5.2.0)
@@ -6,7 +6,8 @@ class Devise::MasqueradesController < DeviseController
6
6
  end
7
7
  skip_before_action :masquerade!, raise: false
8
8
 
9
- prepend_before_action :authenticate_scope!, :masquerade_authorize!
9
+ prepend_before_action :authenticate_scope!, only: :show
10
+ prepend_before_action :masquerade_authorize!
10
11
 
11
12
  before_action :save_masquerade_owner_session, only: :show
12
13
 
@@ -15,6 +16,10 @@ class Devise::MasqueradesController < DeviseController
15
16
  def show
16
17
  self.resource = find_resource
17
18
 
19
+ if resource.class != masquerading_resource_class
20
+ sign_out(send("current_#{masquerading_resource_name}"))
21
+ end
22
+
18
23
  unless resource
19
24
  flash[:error] = "#{masqueraded_resource_class} not found."
20
25
  redirect_to(new_user_session_path) and return
@@ -28,6 +33,10 @@ class Devise::MasqueradesController < DeviseController
28
33
  end
29
34
 
30
35
  def back
36
+ unless send("#{masqueraded_resource_name}_signed_in?")
37
+ head(401) and return
38
+ end
39
+
31
40
  self.resource = find_owner_resource
32
41
 
33
42
  if resource.class != masqueraded_resource_class
@@ -43,7 +43,7 @@ module DeviseMasquerade
43
43
 
44
44
  def #{name}_masquerade_owner
45
45
  return nil unless send(:#{name}_masquerade?)
46
- GlobalID::Locator.locate_signed(Rails.cache.read(:"devise_masquerade_#{name}"), for: 'masquerade')
46
+ GlobalID::Locator.locate_signed(::Rails.cache.read(:"devise_masquerade_#{name}"), for: 'masquerade')
47
47
  end
48
48
 
49
49
  private
@@ -1,3 +1,3 @@
1
1
  module DeviseMasquerade
2
- VERSION = '1.3.1'.freeze
2
+ VERSION = '1.3.3'.freeze
3
3
  end
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
 
19
19
  <% if user_masquerade? %>
20
- <%= link_to "Back masquerade", back_masquerade_path(current_user) %>
20
+ <%= link_to "Back masquerade", back_masquerade_path(User.new) %>
21
21
  <% end %>
22
22
  <% end %>
23
23
 
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.1
4
+ version: 1.3.3
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-02-03 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler