devise-secure_password 1.0.6 → 2.0.1

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.
Files changed (63) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.md +39 -4
  3. data/Dockerfile +1 -1
  4. data/Dockerfile.prev +3 -3
  5. data/Gemfile +2 -1
  6. data/Gemfile.lock +218 -214
  7. data/README.md +33 -10
  8. data/app/controllers/devise/passwords_with_policy_controller.rb +55 -14
  9. data/app/views/devise/passwords_with_policy/edit.html.erb +5 -1
  10. data/config/locales/en.yml +51 -0
  11. data/devise-secure_password.gemspec +22 -23
  12. data/gemfiles/rails_6_0.gemfile +57 -0
  13. data/gemfiles/rails_6_0.gemfile.lock +347 -0
  14. data/gemfiles/rails_6_1.gemfile +57 -0
  15. data/gemfiles/rails_6_1.gemfile.lock +352 -0
  16. data/lib/devise/secure_password.rb +4 -9
  17. data/lib/devise/secure_password/controllers/devise_helpers.rb +4 -50
  18. data/lib/devise/secure_password/controllers/helpers.rb +58 -0
  19. data/lib/devise/secure_password/grammar.rb +13 -0
  20. data/lib/devise/secure_password/models/password_disallows_frequent_changes.rb +3 -1
  21. data/lib/devise/secure_password/models/password_disallows_frequent_reuse.rb +1 -0
  22. data/lib/devise/secure_password/models/password_has_required_content.rb +53 -15
  23. data/lib/devise/secure_password/models/password_requires_regular_updates.rb +0 -2
  24. data/lib/devise/secure_password/version.rb +1 -1
  25. data/lib/support/string/character_counter.rb +3 -1
  26. data/pkg/devise-secure_password-2.0.0.gem +0 -0
  27. data/pkg/devise-secure_password-2.0.1.gem +0 -0
  28. metadata +67 -169
  29. data/coverage/assets/0.10.2/application.css +0 -799
  30. data/coverage/assets/0.10.2/application.js +0 -1707
  31. data/coverage/assets/0.10.2/colorbox/border.png +0 -0
  32. data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
  33. data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
  34. data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
  35. data/coverage/assets/0.10.2/favicon_green.png +0 -0
  36. data/coverage/assets/0.10.2/favicon_red.png +0 -0
  37. data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
  38. data/coverage/assets/0.10.2/loading.gif +0 -0
  39. data/coverage/assets/0.10.2/magnify.png +0 -0
  40. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  41. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  42. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  43. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  44. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  45. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  46. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  47. data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  48. data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
  49. data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  50. data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
  51. data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
  52. data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  53. data/coverage/index.html +0 -4115
  54. data/devise-secure_password-1.0.0.gem +0 -0
  55. data/gemfiles/rails-5_0_6.gemfile +0 -17
  56. data/gemfiles/rails-5_0_6.gemfile.lock +0 -286
  57. data/gemfiles/rails-5_1_4.gemfile +0 -16
  58. data/gemfiles/rails-5_1_4.gemfile.lock +0 -282
  59. data/lib/devise/secure_password/controllers/active_helpers.rb +0 -45
  60. data/lib/devise/secure_password/hooks/password_requires_regular_updates.rb +0 -5
  61. data/pkg/devise-secure_password-1.0.3.gem +0 -0
  62. data/pkg/devise-secure_password-1.0.4.gem +0 -0
  63. data/pkg/devise-secure_password-1.0.5.gem +0 -0
@@ -0,0 +1,57 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ENV['RAILS_TARGET'] ||= '6.1'
5
+
6
+ gemspec path: '../'
7
+
8
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
9
+ gem 'rails', '~> 6.1.3', '>= 6.1.3.1'
10
+ # Use sqlite3 as the database for Active Record
11
+ gem 'sqlite3', '~> 1.4'
12
+ # Use Puma as the app server
13
+ gem 'puma', '~> 5.0'
14
+ # Use SCSS for stylesheets
15
+ gem 'sass-rails', '>= 6'
16
+ # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
17
+ gem 'webpacker', '~> 5.0'
18
+ # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
19
+ gem 'turbolinks', '~> 5'
20
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
21
+ gem 'jbuilder', '~> 2.7'
22
+ # Use Redis adapter to run Action Cable in production
23
+ # gem 'redis', '~> 4.0'
24
+ # Use Active Model has_secure_password
25
+ # gem 'bcrypt', '~> 3.1.7'
26
+
27
+ # Use Active Storage variant
28
+ # gem 'image_processing', '~> 1.2'
29
+
30
+ # Reduces boot times through caching; required in config/boot.rb
31
+ gem 'bootsnap', '>= 1.4.4', require: false
32
+
33
+ group :development, :test do
34
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
35
+ gem 'byebug', platforms: %i(mri mingw x64_mingw)
36
+ end
37
+
38
+ group :development do
39
+ # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
40
+ gem 'listen', '~> 3.3'
41
+ gem 'web-console', '>= 4.1.0'
42
+ end
43
+
44
+ group :test do
45
+ # Adds support for Capybara system testing and selenium driver
46
+ gem 'capybara', '>= 3.26'
47
+ gem 'codecov', require: false
48
+ gem 'selenium-webdriver'
49
+ gem 'shoulda-matchers'
50
+ # Easy installation and use of web drivers to run system tests with browsers
51
+ gem 'webdrivers'
52
+ end
53
+
54
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
55
+ gem 'tzinfo-data', platforms: %i(mingw mswin x64_mingw jruby)
56
+
57
+ gem 'webrick', '~> 1.7'
@@ -0,0 +1,352 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ devise-secure_password (1.1.0)
5
+ devise (>= 4.0.0, < 5.0.0)
6
+ railties (>= 5.0.0, < 7.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.1.3.1)
12
+ actionpack (= 6.1.3.1)
13
+ activesupport (= 6.1.3.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (6.1.3.1)
17
+ actionpack (= 6.1.3.1)
18
+ activejob (= 6.1.3.1)
19
+ activerecord (= 6.1.3.1)
20
+ activestorage (= 6.1.3.1)
21
+ activesupport (= 6.1.3.1)
22
+ mail (>= 2.7.1)
23
+ actionmailer (6.1.3.1)
24
+ actionpack (= 6.1.3.1)
25
+ actionview (= 6.1.3.1)
26
+ activejob (= 6.1.3.1)
27
+ activesupport (= 6.1.3.1)
28
+ mail (~> 2.5, >= 2.5.4)
29
+ rails-dom-testing (~> 2.0)
30
+ actionpack (6.1.3.1)
31
+ actionview (= 6.1.3.1)
32
+ activesupport (= 6.1.3.1)
33
+ rack (~> 2.0, >= 2.0.9)
34
+ rack-test (>= 0.6.3)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.1.3.1)
38
+ actionpack (= 6.1.3.1)
39
+ activerecord (= 6.1.3.1)
40
+ activestorage (= 6.1.3.1)
41
+ activesupport (= 6.1.3.1)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.1.3.1)
44
+ activesupport (= 6.1.3.1)
45
+ builder (~> 3.1)
46
+ erubi (~> 1.4)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.1.3.1)
50
+ activesupport (= 6.1.3.1)
51
+ globalid (>= 0.3.6)
52
+ activemodel (6.1.3.1)
53
+ activesupport (= 6.1.3.1)
54
+ activerecord (6.1.3.1)
55
+ activemodel (= 6.1.3.1)
56
+ activesupport (= 6.1.3.1)
57
+ activestorage (6.1.3.1)
58
+ actionpack (= 6.1.3.1)
59
+ activejob (= 6.1.3.1)
60
+ activerecord (= 6.1.3.1)
61
+ activesupport (= 6.1.3.1)
62
+ marcel (~> 1.0.0)
63
+ mini_mime (~> 1.0.2)
64
+ activesupport (6.1.3.1)
65
+ concurrent-ruby (~> 1.0, >= 1.0.2)
66
+ i18n (>= 1.6, < 2)
67
+ minitest (>= 5.1)
68
+ tzinfo (~> 2.0)
69
+ zeitwerk (~> 2.3)
70
+ addressable (2.7.0)
71
+ public_suffix (>= 2.0.2, < 5.0)
72
+ ansi (1.5.0)
73
+ ast (2.4.2)
74
+ bcrypt (3.1.16)
75
+ bindex (0.8.1)
76
+ bootsnap (1.7.4)
77
+ msgpack (~> 1.0)
78
+ builder (3.2.4)
79
+ byebug (11.1.3)
80
+ capybara (3.35.3)
81
+ addressable
82
+ mini_mime (>= 0.1.3)
83
+ nokogiri (~> 1.8)
84
+ rack (>= 1.6.0)
85
+ rack-test (>= 0.6.3)
86
+ regexp_parser (>= 1.5, < 3.0)
87
+ xpath (~> 3.2)
88
+ capybara-screenshot (1.0.25)
89
+ capybara (>= 1.0, < 4)
90
+ launchy
91
+ childprocess (3.0.0)
92
+ codecov (0.5.2)
93
+ simplecov (>= 0.15, < 0.22)
94
+ concurrent-ruby (1.1.8)
95
+ crass (1.0.6)
96
+ database_cleaner (2.0.1)
97
+ database_cleaner-active_record (~> 2.0.0)
98
+ database_cleaner-active_record (2.0.0)
99
+ activerecord (>= 5.a)
100
+ database_cleaner-core (~> 2.0.0)
101
+ database_cleaner-core (2.0.1)
102
+ devise (4.8.0)
103
+ bcrypt (~> 3.0)
104
+ orm_adapter (~> 0.1)
105
+ railties (>= 4.1.0)
106
+ responders
107
+ warden (~> 1.2.3)
108
+ diff-lcs (1.4.4)
109
+ docile (1.3.5)
110
+ erubi (1.10.0)
111
+ erubis (2.7.0)
112
+ ffi (1.15.0)
113
+ flay (2.12.1)
114
+ erubis (~> 2.7.0)
115
+ path_expander (~> 1.0)
116
+ ruby_parser (~> 3.0)
117
+ sexp_processor (~> 4.0)
118
+ globalid (0.4.2)
119
+ activesupport (>= 4.2.0)
120
+ i18n (1.8.10)
121
+ concurrent-ruby (~> 1.0)
122
+ jbuilder (2.11.2)
123
+ activesupport (>= 5.0.0)
124
+ launchy (2.5.0)
125
+ addressable (~> 2.7)
126
+ listen (3.5.1)
127
+ rb-fsevent (~> 0.10, >= 0.10.3)
128
+ rb-inotify (~> 0.9, >= 0.9.10)
129
+ loofah (2.9.1)
130
+ crass (~> 1.0.2)
131
+ nokogiri (>= 1.5.9)
132
+ mail (2.7.1)
133
+ mini_mime (>= 0.1.1)
134
+ marcel (1.0.1)
135
+ method_source (1.0.0)
136
+ mini_mime (1.0.3)
137
+ mini_portile2 (2.5.1)
138
+ minitest (5.14.4)
139
+ msgpack (1.4.2)
140
+ nio4r (2.5.7)
141
+ nokogiri (1.11.3)
142
+ mini_portile2 (~> 2.5.0)
143
+ racc (~> 1.4)
144
+ orm_adapter (0.5.0)
145
+ parallel (1.20.1)
146
+ parser (3.0.1.1)
147
+ ast (~> 2.4.1)
148
+ path_expander (1.1.0)
149
+ public_suffix (4.0.6)
150
+ puma (5.2.2)
151
+ nio4r (~> 2.0)
152
+ racc (1.5.2)
153
+ rack (2.2.3)
154
+ rack-proxy (0.6.5)
155
+ rack
156
+ rack-test (1.1.0)
157
+ rack (>= 1.0, < 3)
158
+ rails (6.1.3.1)
159
+ actioncable (= 6.1.3.1)
160
+ actionmailbox (= 6.1.3.1)
161
+ actionmailer (= 6.1.3.1)
162
+ actionpack (= 6.1.3.1)
163
+ actiontext (= 6.1.3.1)
164
+ actionview (= 6.1.3.1)
165
+ activejob (= 6.1.3.1)
166
+ activemodel (= 6.1.3.1)
167
+ activerecord (= 6.1.3.1)
168
+ activestorage (= 6.1.3.1)
169
+ activesupport (= 6.1.3.1)
170
+ bundler (>= 1.15.0)
171
+ railties (= 6.1.3.1)
172
+ sprockets-rails (>= 2.0.0)
173
+ rails-dom-testing (2.0.3)
174
+ activesupport (>= 4.2.0)
175
+ nokogiri (>= 1.6)
176
+ rails-html-sanitizer (1.3.0)
177
+ loofah (~> 2.3)
178
+ railties (6.1.3.1)
179
+ actionpack (= 6.1.3.1)
180
+ activesupport (= 6.1.3.1)
181
+ method_source
182
+ rake (>= 0.8.7)
183
+ thor (~> 1.0)
184
+ rainbow (3.0.0)
185
+ rake (13.0.3)
186
+ rb-fsevent (0.10.4)
187
+ rb-inotify (0.10.1)
188
+ ffi (~> 1.0)
189
+ regexp_parser (2.1.1)
190
+ responders (3.0.1)
191
+ actionpack (>= 5.0)
192
+ railties (>= 5.0)
193
+ rexml (3.2.5)
194
+ rspec (3.10.0)
195
+ rspec-core (~> 3.10.0)
196
+ rspec-expectations (~> 3.10.0)
197
+ rspec-mocks (~> 3.10.0)
198
+ rspec-core (3.10.1)
199
+ rspec-support (~> 3.10.0)
200
+ rspec-expectations (3.10.1)
201
+ diff-lcs (>= 1.2.0, < 2.0)
202
+ rspec-support (~> 3.10.0)
203
+ rspec-mocks (3.10.2)
204
+ diff-lcs (>= 1.2.0, < 2.0)
205
+ rspec-support (~> 3.10.0)
206
+ rspec-rails (5.0.1)
207
+ actionpack (>= 5.2)
208
+ activesupport (>= 5.2)
209
+ railties (>= 5.2)
210
+ rspec-core (~> 3.10)
211
+ rspec-expectations (~> 3.10)
212
+ rspec-mocks (~> 3.10)
213
+ rspec-support (~> 3.10)
214
+ rspec-support (3.10.2)
215
+ rspec_junit_formatter (0.4.1)
216
+ rspec-core (>= 2, < 4, != 2.12.0)
217
+ rubocop (1.13.0)
218
+ parallel (~> 1.10)
219
+ parser (>= 3.0.0.0)
220
+ rainbow (>= 2.2.2, < 4.0)
221
+ regexp_parser (>= 1.8, < 3.0)
222
+ rexml
223
+ rubocop-ast (>= 1.2.0, < 2.0)
224
+ ruby-progressbar (~> 1.7)
225
+ unicode-display_width (>= 1.4.0, < 3.0)
226
+ rubocop-ast (1.5.0)
227
+ parser (>= 3.0.1.1)
228
+ rubocop-rails (2.9.1)
229
+ activesupport (>= 4.2.0)
230
+ rack (>= 1.1)
231
+ rubocop (>= 0.90.0, < 2.0)
232
+ rubocop-rspec (2.3.0)
233
+ rubocop (~> 1.0)
234
+ rubocop-ast (>= 1.1.0)
235
+ ruby-progressbar (1.11.0)
236
+ ruby2ruby (2.4.4)
237
+ ruby_parser (~> 3.1)
238
+ sexp_processor (~> 4.6)
239
+ ruby_parser (3.15.1)
240
+ sexp_processor (~> 4.9)
241
+ rubyzip (2.3.0)
242
+ sass-rails (6.0.0)
243
+ sassc-rails (~> 2.1, >= 2.1.1)
244
+ sassc (2.4.0)
245
+ ffi (~> 1.9)
246
+ sassc-rails (2.1.2)
247
+ railties (>= 4.0.0)
248
+ sassc (>= 2.0)
249
+ sprockets (> 3.0)
250
+ sprockets-rails
251
+ tilt
252
+ selenium-webdriver (3.142.7)
253
+ childprocess (>= 0.5, < 4.0)
254
+ rubyzip (>= 1.2.2)
255
+ semantic_range (3.0.0)
256
+ sexp_processor (4.15.2)
257
+ shoulda-matchers (4.5.1)
258
+ activesupport (>= 4.2.0)
259
+ simplecov (0.21.2)
260
+ docile (~> 1.1)
261
+ simplecov-html (~> 0.11)
262
+ simplecov_json_formatter (~> 0.1)
263
+ simplecov-console (0.9.1)
264
+ ansi
265
+ simplecov
266
+ terminal-table
267
+ simplecov-html (0.12.3)
268
+ simplecov_json_formatter (0.1.3)
269
+ sprockets (4.0.2)
270
+ concurrent-ruby (~> 1.0)
271
+ rack (> 1, < 3)
272
+ sprockets-rails (3.2.2)
273
+ actionpack (>= 4.0)
274
+ activesupport (>= 4.0)
275
+ sprockets (>= 3.0.0)
276
+ sqlite3 (1.4.2)
277
+ terminal-table (3.0.0)
278
+ unicode-display_width (~> 1.1, >= 1.1.1)
279
+ thor (1.1.0)
280
+ tilt (2.0.10)
281
+ turbolinks (5.2.1)
282
+ turbolinks-source (~> 5.2)
283
+ turbolinks-source (5.2.0)
284
+ tzinfo (2.0.4)
285
+ concurrent-ruby (~> 1.0)
286
+ unicode-display_width (1.7.0)
287
+ warden (1.2.9)
288
+ rack (>= 2.0.9)
289
+ web-console (4.1.0)
290
+ actionview (>= 6.0.0)
291
+ activemodel (>= 6.0.0)
292
+ bindex (>= 0.4.0)
293
+ railties (>= 6.0.0)
294
+ webdrivers (4.6.0)
295
+ nokogiri (~> 1.6)
296
+ rubyzip (>= 1.3.0)
297
+ selenium-webdriver (>= 3.0, < 4.0)
298
+ webpacker (5.3.0)
299
+ activesupport (>= 5.2)
300
+ rack-proxy (>= 0.6.1)
301
+ railties (>= 5.2)
302
+ semantic_range (>= 2.3.0)
303
+ webrick (1.7.0)
304
+ websocket-driver (0.7.3)
305
+ websocket-extensions (>= 0.1.0)
306
+ websocket-extensions (0.1.5)
307
+ xpath (3.2.0)
308
+ nokogiri (~> 1.8)
309
+ zeitwerk (2.4.2)
310
+
311
+ PLATFORMS
312
+ ruby
313
+
314
+ DEPENDENCIES
315
+ bootsnap (>= 1.4.4)
316
+ bundler (>= 2.2.16)
317
+ byebug
318
+ capybara (>= 3.26)
319
+ capybara-screenshot (>= 1.0.18)
320
+ codecov
321
+ database_cleaner (>= 2.0.1)
322
+ devise (~> 4.0)
323
+ devise-secure_password!
324
+ flay (>= 2.10.0)
325
+ jbuilder (~> 2.7)
326
+ launchy (>= 2.4.3)
327
+ listen (~> 3.3)
328
+ puma (~> 5.0)
329
+ rails (~> 6.1.3, >= 6.1.3.1)
330
+ rake (>= 12.3)
331
+ rspec (>= 3.7)
332
+ rspec-rails (>= 3.7)
333
+ rspec_junit_formatter (>= 0.3)
334
+ rubocop (>= 1.0.0)
335
+ rubocop-rails (>= 2.3.2)
336
+ rubocop-rspec (>= 1.35.0)
337
+ ruby2ruby (>= 2.4.0)
338
+ sass-rails (>= 6)
339
+ selenium-webdriver
340
+ shoulda-matchers
341
+ simplecov (>= 0.18.2)
342
+ simplecov-console (>= 0.4.2)
343
+ sqlite3 (~> 1.4)
344
+ turbolinks (~> 5)
345
+ tzinfo-data
346
+ web-console (>= 4.1.0)
347
+ webdrivers
348
+ webpacker (~> 5.0)
349
+ webrick (~> 1.7)
350
+
351
+ BUNDLED WITH
352
+ 2.2.16
@@ -9,6 +9,7 @@ require 'devise/secure_password/models/password_has_required_content'
9
9
  require 'devise/secure_password/models/password_disallows_frequent_reuse'
10
10
  require 'devise/secure_password/models/password_disallows_frequent_changes'
11
11
  require 'devise/secure_password/models/password_requires_regular_updates'
12
+ require 'devise/secure_password/grammar'
12
13
 
13
14
  module Devise
14
15
  # password_content_enforcement configuration parameters
@@ -27,19 +28,13 @@ module Devise
27
28
  @password_maximum_age = 180.days
28
29
 
29
30
  class << self
30
- attr_accessor :password_required_uppercase_count
31
- attr_accessor :password_required_lowercase_count
32
- attr_accessor :password_required_number_count
33
- attr_accessor :password_required_special_character_count
34
- attr_accessor :password_previously_used_count
35
- attr_accessor :password_minimum_age
36
- attr_accessor :password_maximum_age
31
+ attr_accessor :password_required_uppercase_count, :password_required_lowercase_count, :password_required_number_count, :password_required_special_character_count, :password_previously_used_count, :password_minimum_age, :password_maximum_age
37
32
  end
38
33
 
39
34
  module SecurePassword
40
35
  module Controllers
36
+ autoload :Helpers, 'devise/secure_password/controllers/helpers'
41
37
  autoload :DeviseHelpers, 'devise/secure_password/controllers/devise_helpers'
42
- autoload :ActiveHelpers, 'devise/secure_password/controllers/active_helpers'
43
38
  end
44
39
 
45
40
  class Engine < ::Rails::Engine
@@ -49,7 +44,7 @@ module Devise
49
44
  end
50
45
  ActiveSupport.on_load(:action_controller) do
51
46
  include ActionView::Helpers::DateHelper
52
- include Devise::SecurePassword::Controllers::ActiveHelpers
47
+ include Devise::SecurePassword::Controllers::Helpers
53
48
  end
54
49
 
55
50
  # add exceptions to the inflector so it doesn't get tripped up by our concerns that end in an 's'
@@ -4,63 +4,17 @@ module Devise
4
4
  module DeviseHelpers
5
5
  extend ActiveSupport::Concern
6
6
 
7
- # rubocop:disable Style/ClassAndModuleChildren
8
7
  class ::DeviseController
9
- alias old_require_no_authentication require_no_authentication
8
+ alias devise_sign_in sign_in
10
9
 
11
10
  protected
12
11
 
13
- # Override the devise require_no_authentication before callback to
14
- # prevent authenticated users with expired passwords from escaping to
15
- # other pages without first updating their passwords.
16
- def require_no_authentication
17
- return if check_password_expired_and_redirect!
18
-
19
- old_require_no_authentication
20
- end
21
-
22
- # Store the name of the current controller and action in the warden
23
- # session store then redirect if signed in and password expired. The
24
- # stored values will be used by non-devise controllers to prevent a
25
- # user from escaping the change password process.
26
- def check_password_expired_and_redirect!
27
- assert_is_devise_resource!
28
-
29
- return if skip_current_devise_controller?
30
-
31
- if signed_in?(scope_name) && warden.session(scope_name)[:secure_password_expired]
32
- save_controller_state
33
- redirect_to edit_user_password_with_policy_url, alert: "#{error_string_for_password_expired}."
34
- return true
12
+ def sign_in(*args)
13
+ devise_sign_in(*args).tap do
14
+ set_devise_secure_password_expired! if warden_user_has_password_expiration?
35
15
  end
36
-
37
- false
38
- end
39
-
40
- def save_controller_state
41
- warden.session(scope_name)[:secure_last_controller] = self.class.name
42
- warden.session(scope_name)[:secure_last_action] = action_name
43
- end
44
-
45
- # Prevent infinite loops and allow specified controllers to bypass.
46
- # @NOTE: The ability to extend this list may be made public, in the
47
- # future if that functionality is needed.
48
- def skip_current_devise_controller?
49
- exclusion_list = [
50
- 'Devise::SessionsController'
51
- ]
52
- !(exclusion_list.include?("#{self.class.name}#" + action_name) || (exclusion_list & self.class.ancestors.map(&:to_s)).any?)
53
- end
54
-
55
- def error_string_for_password_expired
56
- class_obj = scope_name.to_s.camelize.constantize
57
- I18n.t(
58
- 'secure_password.password_requires_regular_updates.errors.messages.password_expired',
59
- timeframe: distance_of_time_in_words(class_obj.password_maximum_age)
60
- )
61
16
  end
62
17
  end
63
- # rubocop:enable Style/ClassAndModuleChildren
64
18
  end
65
19
  end
66
20
  end