devise_masquerade 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/devise/masquerades_controller.rb +0 -30
- data/features/back.feature +2 -0
- data/features/expires_masquerade.feature +2 -0
- data/features/step_definitions/back_steps.rb +4 -0
- data/lib/devise_masquerade/controllers/helpers.rb +43 -5
- data/lib/devise_masquerade/version.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21015ee6b3b1561bcf507063f84e0eea7f0bd4db78bee58c2122b287628cc56
|
4
|
+
data.tar.gz: 6817e192073914e507c1ba3cf7b9bef3178e733b3b83314ff80914f827e612d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db0d98e2513d372a40896dfd4453359e5d04a3865300c0c96407582e1a6601d52528dced610830bb95b527ea416ea60b212d8de1a286a1b56706d6c4dbb41451
|
7
|
+
data.tar.gz: 70fdb0e0e55321832ce09c00613ca5c26faff9f2dc7587523b09d61cbcdcfc66fbf3e3368a898cc39564057cae97a1b96ad668c53812e8b5bfbc5e28749eafe2
|
data/Gemfile.lock
CHANGED
@@ -98,24 +98,6 @@ class Devise::MasqueradesController < DeviseController
|
|
98
98
|
|
99
99
|
private
|
100
100
|
|
101
|
-
def masqueraded_resource_class
|
102
|
-
@masqueraded_resource_class ||= begin
|
103
|
-
unless params[:masqueraded_resource_class].blank?
|
104
|
-
params[:masqueraded_resource_class].constantize
|
105
|
-
else
|
106
|
-
unless session[session_key_masqueraded_resource_class].blank?
|
107
|
-
session[session_key_masquerading_resource_class].constantize
|
108
|
-
else
|
109
|
-
if Devise.masqueraded_resource_class_name.present?
|
110
|
-
Devise.masqueraded_resource_class_name.constantize
|
111
|
-
else
|
112
|
-
Devise.masqueraded_resource_class || resource_class
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
101
|
def masqueraded_resource_name
|
120
102
|
Devise.masqueraded_resource_name || masqueraded_resource_class.model_name.param_key
|
121
103
|
end
|
@@ -193,18 +175,6 @@ class Devise::MasqueradesController < DeviseController
|
|
193
175
|
"devise_masquerade_#{masqueraded_resource_name}_#{masqueradable_resource.to_param}_#{guid}".to_sym
|
194
176
|
end
|
195
177
|
|
196
|
-
def session_key_masqueraded_resource_class
|
197
|
-
"devise_masquerade_masqueraded_resource_class"
|
198
|
-
end
|
199
|
-
|
200
|
-
def session_key_masquerading_resource_class
|
201
|
-
"devise_masquerade_masquerading_resource_class"
|
202
|
-
end
|
203
|
-
|
204
|
-
def session_key_masquerading_resource_guid
|
205
|
-
"devise_masquerade_masquerading_resource_guid"
|
206
|
-
end
|
207
|
-
|
208
178
|
def masquerading_current_user
|
209
179
|
send("current_#{masquerading_resource_name}")
|
210
180
|
end
|
data/features/back.feature
CHANGED
@@ -11,6 +11,7 @@ Feature: Use back button for returning to the owner of the masquerade action.
|
|
11
11
|
When I am on the users page
|
12
12
|
And I login as one user
|
13
13
|
Then I should be login as this user
|
14
|
+
And I should be masqueraded by owner user
|
14
15
|
|
15
16
|
When I press back masquerade button
|
16
17
|
Then I should be login as owner user
|
@@ -23,6 +24,7 @@ Feature: Use back button for returning to the owner of the masquerade action.
|
|
23
24
|
When I am on the users page
|
24
25
|
And I login as one user
|
25
26
|
Then I should be login as this user
|
27
|
+
And I should be masqueraded by owner user
|
26
28
|
|
27
29
|
When I press back masquerade button
|
28
30
|
Then I should be login as owner user
|
@@ -13,6 +13,7 @@ Feature: Use back button for returning to the owner despite on expiration time.
|
|
13
13
|
When I am on the users page
|
14
14
|
And I login as one user
|
15
15
|
Then I should be login as this user
|
16
|
+
And I should be masqueraded by owner user
|
16
17
|
And I waited for 2 seconds
|
17
18
|
|
18
19
|
When I press back masquerade button
|
@@ -28,6 +29,7 @@ Feature: Use back button for returning to the owner despite on expiration time.
|
|
28
29
|
When I am on the users page
|
29
30
|
And I login as one user
|
30
31
|
Then I should be login as this user
|
32
|
+
And I should be masqueraded by owner user
|
31
33
|
And I waited for 2 seconds
|
32
34
|
|
33
35
|
When I press back masquerade button
|
@@ -14,6 +14,10 @@ Then /^I should be login as this user$/ do
|
|
14
14
|
find('.current_user').should have_content(@user_mask.email)
|
15
15
|
end
|
16
16
|
|
17
|
+
Then /^I should be masqueraded by owner user$/ do
|
18
|
+
find('.owner_user').should have_content(@user.email)
|
19
|
+
end
|
20
|
+
|
17
21
|
When /^I press back masquerade button$/ do
|
18
22
|
click_on "Back masquerade"
|
19
23
|
end
|
@@ -53,13 +53,15 @@ module DeviseMasquerade
|
|
53
53
|
def #{name}_masquerade_owner
|
54
54
|
return unless send(:#{name}_masquerade?)
|
55
55
|
|
56
|
-
|
57
|
-
session[#{name}_helper_session_key]
|
56
|
+
if Devise.masquerade_storage_method_session?
|
57
|
+
resource_id = session[#{name}_helper_session_key]
|
58
|
+
|
59
|
+
masqueraded_resource_class.find(resource_id)
|
58
60
|
else
|
59
|
-
::Rails.cache.read(#{name}_helper_session_key)
|
60
|
-
end
|
61
|
+
sgid = ::Rails.cache.read(#{name}_helper_session_key)
|
61
62
|
|
62
|
-
|
63
|
+
GlobalID::Locator.locate_signed(sgid, for: 'masquerade')
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
67
|
private
|
@@ -83,12 +85,48 @@ module DeviseMasquerade
|
|
83
85
|
sign_in(resource)
|
84
86
|
end
|
85
87
|
end
|
88
|
+
|
89
|
+
def masqueraded_resource_class
|
90
|
+
@masqueraded_resource_class ||= begin
|
91
|
+
unless params[:masqueraded_resource_class].blank?
|
92
|
+
params[:masqueraded_resource_class].constantize
|
93
|
+
else
|
94
|
+
unless session[session_key_masqueraded_resource_class].blank?
|
95
|
+
session[session_key_masquerading_resource_class].constantize
|
96
|
+
else
|
97
|
+
if Devise.masqueraded_resource_class_name.present?
|
98
|
+
Devise.masqueraded_resource_class_name.constantize
|
99
|
+
else
|
100
|
+
Devise.masqueraded_resource_class || resource_class
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def session_key_masqueraded_resource_class
|
108
|
+
"devise_masquerade_masqueraded_resource_class"
|
109
|
+
end
|
110
|
+
|
111
|
+
def session_key_masquerading_resource_class
|
112
|
+
"devise_masquerade_masquerading_resource_class"
|
113
|
+
end
|
114
|
+
|
115
|
+
def session_key_masquerading_resource_guid
|
116
|
+
"devise_masquerade_masquerading_resource_guid"
|
117
|
+
end
|
118
|
+
|
86
119
|
METHODS
|
87
120
|
|
88
121
|
ActiveSupport.on_load(:action_controller) do
|
89
122
|
if respond_to?(:helper_method)
|
90
123
|
helper_method "#{name}_masquerade?"
|
91
124
|
helper_method "#{name}_masquerade_owner"
|
125
|
+
|
126
|
+
helper_method :masqueraded_resource_class
|
127
|
+
helper_method :session_key_masqueraded_resource_class
|
128
|
+
helper_method :session_key_masquerading_resource_class
|
129
|
+
helper_method :session_key_masquerading_resource_guid
|
92
130
|
end
|
93
131
|
end
|
94
132
|
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: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandr Korsak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|