devise_masquerade 2.0.1 → 2.0.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: 0e7178dc0f54d070a2f4e839f320f65c5506b215a902cc2180b8e357d1a9f62d
4
- data.tar.gz: 5466190dbaae779ca45abaa8e65f526e1b99805a493019c8dc67572d387b8022
3
+ metadata.gz: 4c0668fdf45d72f5919bd9ca487fe2b664948fc9399029832cc426500c030daa
4
+ data.tar.gz: f61869c2877366a03922b6f0a8aecce6d9adea6a48f1f006a6311d97a2b83d2a
5
5
  SHA512:
6
- metadata.gz: f2b85a5241c5aef644ca6139f89807631b6e93ebcbc2fc77f0b88f74e43bd411a056bb49c3340ae63322e22cf13a5ca4185208d7c8c778e124d04fa37bb19cbd
7
- data.tar.gz: 374dacc212988505fca5cfea9188a7fcdce44d174b54b3cd980363b37c377bb92713ab8467858eefa62d23568783e09929bcdace08efa344bf5610f382e32f31
6
+ metadata.gz: d98eefe89ce90e177bffdf7d81bdcb7904351d4a8e2de9b519c91e9a81b998398339bdfbbf922146c177b739f22a140b450b5cda5afa4f578d254e02f443f0f7
7
+ data.tar.gz: f2120c2b253f5f306589abd2b259607e3959e6910e7a8d5cf9661198a5b36a7d0372391995ef8b633a50cc6109e90f500a4dac3603950000eff1419b509cd9ac
data/Gemfile.lock CHANGED
@@ -52,7 +52,7 @@ GIT
52
52
  PATH
53
53
  remote: .
54
54
  specs:
55
- devise_masquerade (2.0.1)
55
+ devise_masquerade (2.0.3)
56
56
  devise (>= 4.7.0)
57
57
  globalid (>= 0.3.6)
58
58
  railties (>= 5.2.0)
@@ -104,22 +104,23 @@ GEM
104
104
  bson (~> 1.12.5)
105
105
  builder (3.2.3)
106
106
  byebug (11.0.1)
107
- capybara (3.29.0)
107
+ capybara (3.37.1)
108
108
  addressable
109
+ matrix
109
110
  mini_mime (>= 0.1.3)
110
111
  nokogiri (~> 1.8)
111
112
  rack (>= 1.6.0)
112
113
  rack-test (>= 0.6.3)
113
- regexp_parser (~> 1.5)
114
+ regexp_parser (>= 1.5, < 3.0)
114
115
  xpath (~> 3.2)
115
116
  childprocess (3.0.0)
116
117
  chromedriver-helper (2.1.1)
117
118
  archive-zip (~> 0.10)
118
119
  nokogiri (~> 1.8)
119
- coderay (1.1.2)
120
+ coderay (1.1.3)
120
121
  concurrent-ruby (1.1.5)
121
122
  crass (1.0.6)
122
- cucumber (3.1.2)
123
+ cucumber (3.2.0)
123
124
  builder (>= 2.1.2)
124
125
  cucumber-core (~> 3.2.0)
125
126
  cucumber-expressions (~> 6.0.1)
@@ -148,7 +149,7 @@ GEM
148
149
  railties (>= 4.1.0)
149
150
  responders
150
151
  warden (~> 1.2.3)
151
- diff-lcs (1.3)
152
+ diff-lcs (1.5.0)
152
153
  erubi (1.9.0)
153
154
  factory_bot (5.1.1)
154
155
  activesupport (>= 4.2.0)
@@ -160,7 +161,7 @@ GEM
160
161
  gherkin (5.1.0)
161
162
  globalid (0.4.2)
162
163
  activesupport (>= 4.2.0)
163
- guard (2.15.1)
164
+ guard (2.17.0)
164
165
  formatador (>= 0.2.4)
165
166
  listen (>= 2.7, < 4.0)
166
167
  lumberjack (>= 1.0.12, < 2.0)
@@ -169,8 +170,8 @@ GEM
169
170
  pry (>= 0.9.12)
170
171
  shellany (~> 0.0)
171
172
  thor (>= 0.18.1)
172
- guard-bundler (2.2.1)
173
- bundler (>= 1.3.0, < 3)
173
+ guard-bundler (3.0.0)
174
+ bundler (>= 2.1, < 3)
174
175
  guard (~> 2.2)
175
176
  guard-compat (~> 1.1)
176
177
  guard-compat (1.2.1)
@@ -184,10 +185,10 @@ GEM
184
185
  rspec (>= 2.99.0, < 4.0)
185
186
  i18n (1.7.0)
186
187
  concurrent-ruby (~> 1.0)
187
- io-like (0.3.0)
188
+ io-like (0.3.1)
188
189
  launchy (2.4.3)
189
190
  addressable (~> 2.3)
190
- listen (3.2.0)
191
+ listen (3.7.1)
191
192
  rb-fsevent (~> 0.10, >= 0.10.3)
192
193
  rb-inotify (~> 0.9, >= 0.9.10)
193
194
  loofah (2.18.0)
@@ -196,17 +197,18 @@ GEM
196
197
  lumberjack (1.0.13)
197
198
  mail (2.7.1)
198
199
  mini_mime (>= 0.1.1)
200
+ matrix (0.4.2)
199
201
  method_source (0.9.2)
200
202
  mime-types (3.3)
201
203
  mime-types-data (~> 3.2015)
202
204
  mime-types-data (3.2019.1009)
203
205
  mini_mime (1.0.2)
204
206
  mini_portile2 (2.8.0)
205
- minitest (5.12.2)
207
+ minitest (5.16.3)
206
208
  multi_json (1.14.1)
207
209
  multi_test (0.1.2)
208
210
  nenv (0.3.0)
209
- nokogiri (1.13.6)
211
+ nokogiri (1.13.9)
210
212
  mini_portile2 (~> 2.8.0)
211
213
  racc (~> 1.4)
212
214
  notiffany (0.1.3)
@@ -217,14 +219,14 @@ GEM
217
219
  pry (0.12.2)
218
220
  coderay (~> 1.1.0)
219
221
  method_source (~> 0.9.0)
220
- pry-byebug (3.7.0)
222
+ pry-byebug (3.8.0)
221
223
  byebug (~> 11.0)
222
224
  pry (~> 0.10)
223
225
  public_suffix (4.0.6)
224
226
  racc (1.6.0)
225
227
  rack (2.2.3.1)
226
- rack-test (1.1.0)
227
- rack (>= 1.0, < 3)
228
+ rack-test (2.0.2)
229
+ rack (>= 1.3)
228
230
  rails-dom-testing (2.0.3)
229
231
  activesupport (>= 4.2.0)
230
232
  nokogiri (>= 1.6)
@@ -240,7 +242,7 @@ GEM
240
242
  rb-fsevent (0.10.3)
241
243
  rb-inotify (0.10.0)
242
244
  ffi (~> 1.0)
243
- regexp_parser (1.6.0)
245
+ regexp_parser (2.6.0)
244
246
  responders (3.0.1)
245
247
  actionpack (>= 5.0)
246
248
  railties (>= 5.0)
@@ -255,7 +257,8 @@ GEM
255
257
  shoulda-context (1.2.2)
256
258
  shoulda-matchers (3.1.3)
257
259
  activesupport (>= 4.0.0)
258
- sqlite3 (1.4.1)
260
+ sqlite3 (1.5.3)
261
+ mini_portile2 (~> 2.8.0)
259
262
  test-unit (3.3.4)
260
263
  power_assert
261
264
  thor (0.20.3)
@@ -266,7 +269,7 @@ GEM
266
269
  rack (>= 2.0.9)
267
270
  xpath (3.2.0)
268
271
  nokogiri (~> 1.8)
269
- zeitwerk (2.2.0)
272
+ zeitwerk (2.6.1)
270
273
 
271
274
  PLATFORMS
272
275
  ruby
@@ -80,7 +80,7 @@ class Devise::MasqueradesController < DeviseController
80
80
  if Devise.masquerade_storage_method_session?
81
81
  resource_id = session[skey]
82
82
 
83
- masqueraded_resource_class.find(resource_id)
83
+ masquerading_resource_class.find(resource_id)
84
84
  else
85
85
  data = Rails.cache.read(skey)
86
86
 
@@ -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
@@ -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
- sgid = if Devise.masquerade_storage_method_session?
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
- GlobalID::Locator.locate_signed(sgid, for: 'masquerade')
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
@@ -1,3 +1,3 @@
1
1
  module DeviseMasquerade
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
@@ -17,6 +17,8 @@
17
17
  <% end %>
18
18
 
19
19
  <% if user_masquerade? %>
20
+ <h1 class='owner_user'><%= user_masquerade_owner.email %></h1>
21
+
20
22
  <%= link_to "Back masquerade", back_masquerade_path(User.new) %>
21
23
  <% end %>
22
24
  <% 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.1
4
+ version: 2.0.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: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler