devise 4.7.2 → 4.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +70 -1
- data/MIT-LICENSE +1 -1
- data/README.md +55 -29
- data/app/controllers/devise/confirmations_controller.rb +1 -0
- data/app/controllers/devise/passwords_controller.rb +2 -2
- data/app/controllers/devise/registrations_controller.rb +1 -1
- data/app/controllers/devise/sessions_controller.rb +1 -1
- data/app/controllers/devise/unlocks_controller.rb +1 -0
- data/app/controllers/devise_controller.rb +1 -0
- data/app/helpers/devise_helper.rb +18 -6
- data/app/mailers/devise/mailer.rb +5 -5
- data/app/views/devise/registrations/edit.html.erb +1 -1
- data/app/views/devise/shared/_error_messages.html.erb +1 -1
- data/app/views/devise/shared/_links.html.erb +1 -1
- data/config/locales/en.yml +1 -1
- data/lib/devise/controllers/helpers.rb +7 -7
- data/lib/devise/controllers/responder.rb +35 -0
- data/lib/devise/controllers/sign_in_out.rb +6 -4
- data/lib/devise/controllers/url_helpers.rb +1 -1
- data/lib/devise/failure_app.rb +6 -3
- data/lib/devise/hooks/csrf_cleaner.rb +6 -1
- data/lib/devise/hooks/lockable.rb +2 -5
- data/lib/devise/mapping.rb +1 -1
- data/lib/devise/models/authenticatable.rb +11 -7
- data/lib/devise/models/confirmable.rb +18 -39
- data/lib/devise/models/database_authenticatable.rb +9 -28
- data/lib/devise/models/lockable.rb +11 -3
- data/lib/devise/models/omniauthable.rb +2 -2
- data/lib/devise/models/recoverable.rb +8 -19
- data/lib/devise/models/rememberable.rb +1 -1
- data/lib/devise/models/timeoutable.rb +1 -1
- data/lib/devise/models/validatable.rb +4 -9
- data/lib/devise/models.rb +1 -0
- data/lib/devise/omniauth.rb +2 -5
- data/lib/devise/orm.rb +71 -0
- data/lib/devise/rails/deprecated_constant_accessor.rb +39 -0
- data/lib/devise/rails/routes.rb +4 -4
- data/lib/devise/test/controller_helpers.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +30 -7
- data/lib/generators/active_record/devise_generator.rb +17 -2
- data/lib/generators/devise/devise_generator.rb +1 -1
- data/lib/generators/devise/install_generator.rb +1 -1
- data/lib/generators/templates/devise.rb +10 -8
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +1 -1
- metadata +17 -5
data/lib/devise.rb
CHANGED
@@ -13,6 +13,7 @@ module Devise
|
|
13
13
|
autoload :Encryptor, 'devise/encryptor'
|
14
14
|
autoload :FailureApp, 'devise/failure_app'
|
15
15
|
autoload :OmniAuth, 'devise/omniauth'
|
16
|
+
autoload :Orm, 'devise/orm'
|
16
17
|
autoload :ParameterFilter, 'devise/parameter_filter'
|
17
18
|
autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
|
18
19
|
autoload :TestHelpers, 'devise/test_helpers'
|
@@ -23,6 +24,7 @@ module Devise
|
|
23
24
|
module Controllers
|
24
25
|
autoload :Helpers, 'devise/controllers/helpers'
|
25
26
|
autoload :Rememberable, 'devise/controllers/rememberable'
|
27
|
+
autoload :Responder, 'devise/controllers/responder'
|
26
28
|
autoload :ScopedViews, 'devise/controllers/scoped_views'
|
27
29
|
autoload :SignInOut, 'devise/controllers/sign_in_out'
|
28
30
|
autoload :StoreLocation, 'devise/controllers/store_location'
|
@@ -217,7 +219,16 @@ module Devise
|
|
217
219
|
|
218
220
|
# Which formats should be treated as navigational.
|
219
221
|
mattr_accessor :navigational_formats
|
220
|
-
@@navigational_formats = ["*/*", :html]
|
222
|
+
@@navigational_formats = ["*/*", :html, :turbo_stream]
|
223
|
+
|
224
|
+
# The default responder used by Devise, used to customize status codes with:
|
225
|
+
#
|
226
|
+
# `config.responder.error_status`
|
227
|
+
# `config.responder.redirect_status`
|
228
|
+
#
|
229
|
+
# Can be replaced by a custom application responder.
|
230
|
+
mattr_accessor :responder
|
231
|
+
@@responder = Devise::Controllers::Responder
|
221
232
|
|
222
233
|
# When set to true, signing out a user signs out all other scopes.
|
223
234
|
mattr_accessor :sign_out_all_scopes
|
@@ -297,10 +308,6 @@ module Devise
|
|
297
308
|
mattr_accessor :sign_in_after_change_password
|
298
309
|
@@sign_in_after_change_password = true
|
299
310
|
|
300
|
-
def self.activerecord51? # :nodoc:
|
301
|
-
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
|
302
|
-
end
|
303
|
-
|
304
311
|
# Default way to set up Devise. Run rails generate devise_install to create
|
305
312
|
# a fresh initializer with all configuration values.
|
306
313
|
def self.setup
|
@@ -313,12 +320,20 @@ module Devise
|
|
313
320
|
end
|
314
321
|
|
315
322
|
def get
|
316
|
-
|
323
|
+
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
|
324
|
+
if ActiveSupport::Dependencies.respond_to?(:constantize)
|
325
|
+
ActiveSupport::Dependencies.constantize(@name)
|
326
|
+
else
|
327
|
+
@name.constantize
|
328
|
+
end
|
317
329
|
end
|
318
330
|
end
|
319
331
|
|
320
332
|
def self.ref(arg)
|
321
|
-
|
333
|
+
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
|
334
|
+
if ActiveSupport::Dependencies.respond_to?(:reference)
|
335
|
+
ActiveSupport::Dependencies.reference(arg)
|
336
|
+
end
|
322
337
|
Getter.new(arg)
|
323
338
|
end
|
324
339
|
|
@@ -505,6 +520,14 @@ module Devise
|
|
505
520
|
b.each_byte { |byte| res |= byte ^ l.shift }
|
506
521
|
res == 0
|
507
522
|
end
|
523
|
+
|
524
|
+
def self.activerecord51? # :nodoc:
|
525
|
+
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
526
|
+
[Devise] `Devise.activerecord51?` is deprecated and will be removed in the next major version.
|
527
|
+
It is a non-public method that's no longer used internally, but that other libraries have been relying on.
|
528
|
+
DEPRECATION
|
529
|
+
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
|
530
|
+
end
|
508
531
|
end
|
509
532
|
|
510
533
|
require 'warden'
|
@@ -86,9 +86,24 @@ RUBY
|
|
86
86
|
Rails::VERSION::MAJOR >= 5
|
87
87
|
end
|
88
88
|
|
89
|
+
def rails61_and_up?
|
90
|
+
Rails::VERSION::MAJOR > 6 || (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1)
|
91
|
+
end
|
92
|
+
|
89
93
|
def postgresql?
|
90
|
-
|
91
|
-
|
94
|
+
ar_config && ar_config['adapter'] == 'postgresql'
|
95
|
+
end
|
96
|
+
|
97
|
+
def ar_config
|
98
|
+
if ActiveRecord::Base.configurations.respond_to?(:configs_for)
|
99
|
+
if rails61_and_up?
|
100
|
+
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").configuration_hash
|
101
|
+
else
|
102
|
+
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: "primary").config
|
103
|
+
end
|
104
|
+
else
|
105
|
+
ActiveRecord::Base.configurations[Rails.env]
|
106
|
+
end
|
92
107
|
end
|
93
108
|
|
94
109
|
def migration_version
|
@@ -13,7 +13,7 @@ module Devise
|
|
13
13
|
desc "Generates a model with the given NAME (if one does not exist) with devise " \
|
14
14
|
"configuration plus a migration file and devise routes."
|
15
15
|
|
16
|
-
hook_for :orm,
|
16
|
+
hook_for :orm, required: true
|
17
17
|
|
18
18
|
class_option :routes, desc: "Generate routes", type: :boolean, default: true
|
19
19
|
|
@@ -11,7 +11,7 @@ module Devise
|
|
11
11
|
source_root File.expand_path("../../templates", __FILE__)
|
12
12
|
|
13
13
|
desc "Creates a Devise initializer and copy locale files to your application."
|
14
|
-
class_option :orm
|
14
|
+
class_option :orm, required: true
|
15
15
|
|
16
16
|
def copy_initializer
|
17
17
|
unless options[:orm]
|
@@ -256,14 +256,14 @@ Devise.setup do |config|
|
|
256
256
|
|
257
257
|
# ==> Navigation configuration
|
258
258
|
# Lists the formats that should be treated as navigational. Formats like
|
259
|
-
# :html
|
259
|
+
# :html should redirect to the sign in page when the user does not have
|
260
260
|
# access, but formats like :xml or :json, should return 401.
|
261
261
|
#
|
262
262
|
# If you have any extra navigational formats, like :iphone or :mobile, you
|
263
263
|
# should add them to the navigational formats lists.
|
264
264
|
#
|
265
265
|
# The "*/*" below is required to match Internet Explorer requests.
|
266
|
-
# config.navigational_formats = ['*/*', :html]
|
266
|
+
# config.navigational_formats = ['*/*', :html, :turbo_stream]
|
267
267
|
|
268
268
|
# The default HTTP method used to sign out a resource. Default is :delete.
|
269
269
|
config.sign_out_via = :delete
|
@@ -296,12 +296,14 @@ Devise.setup do |config|
|
|
296
296
|
# so you need to do it manually. For the users scope, it would be:
|
297
297
|
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
298
298
|
|
299
|
-
# ==>
|
300
|
-
#
|
301
|
-
#
|
302
|
-
#
|
303
|
-
#
|
304
|
-
#
|
299
|
+
# ==> Hotwire/Turbo configuration
|
300
|
+
# When using Devise with Hotwire/Turbo, the http status for error responses
|
301
|
+
# and some redirects must match the following. The default in Devise for existing
|
302
|
+
# apps is `200 OK` and `302 Found respectively`, but new apps are generated with
|
303
|
+
# these new defaults that match Hotwire/Turbo behavior.
|
304
|
+
# Note: These might become the new default in future versions of Devise.
|
305
|
+
config.responder.error_status = :unprocessable_entity
|
306
|
+
config.responder.redirect_status = :see_other
|
305
307
|
|
306
308
|
# ==> Configuration for :registerable
|
307
309
|
|
@@ -30,6 +30,6 @@
|
|
30
30
|
|
31
31
|
<h3>Cancel my account</h3>
|
32
32
|
|
33
|
-
<
|
33
|
+
<div>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></div>
|
34
34
|
|
35
35
|
<%= link_to "Back", :back %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: warden
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/devise.rb
|
118
118
|
- lib/devise/controllers/helpers.rb
|
119
119
|
- lib/devise/controllers/rememberable.rb
|
120
|
+
- lib/devise/controllers/responder.rb
|
120
121
|
- lib/devise/controllers/scoped_views.rb
|
121
122
|
- lib/devise/controllers/sign_in_out.rb
|
122
123
|
- lib/devise/controllers/store_location.rb
|
@@ -150,11 +151,13 @@ files:
|
|
150
151
|
- lib/devise/omniauth.rb
|
151
152
|
- lib/devise/omniauth/config.rb
|
152
153
|
- lib/devise/omniauth/url_helpers.rb
|
154
|
+
- lib/devise/orm.rb
|
153
155
|
- lib/devise/orm/active_record.rb
|
154
156
|
- lib/devise/orm/mongoid.rb
|
155
157
|
- lib/devise/parameter_filter.rb
|
156
158
|
- lib/devise/parameter_sanitizer.rb
|
157
159
|
- lib/devise/rails.rb
|
160
|
+
- lib/devise/rails/deprecated_constant_accessor.rb
|
158
161
|
- lib/devise/rails/routes.rb
|
159
162
|
- lib/devise/rails/warden_compat.rb
|
160
163
|
- lib/devise/secret_key_finder.rb
|
@@ -201,8 +204,17 @@ files:
|
|
201
204
|
homepage: https://github.com/heartcombo/devise
|
202
205
|
licenses:
|
203
206
|
- MIT
|
204
|
-
metadata:
|
205
|
-
|
207
|
+
metadata:
|
208
|
+
homepage_uri: https://github.com/heartcombo/devise
|
209
|
+
documentation_uri: https://rubydoc.info/github/heartcombo/devise
|
210
|
+
changelog_uri: https://github.com/heartcombo/devise/blob/main/CHANGELOG.md
|
211
|
+
source_code_uri: https://github.com/heartcombo/devise
|
212
|
+
bug_tracker_uri: https://github.com/heartcombo/devise/issues
|
213
|
+
wiki_uri: https://github.com/heartcombo/devise/wiki
|
214
|
+
post_install_message: "\n[DEVISE] Please review the [changelog] and [upgrade guide]
|
215
|
+
for more info on Hotwire / Turbo integration.\n\n [changelog] https://github.com/heartcombo/devise/blob/main/CHANGELOG.md\n
|
216
|
+
\ [upgrade guide] https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-%5BHotwire-Turbo-integration%5D\n
|
217
|
+
\ "
|
206
218
|
rdoc_options: []
|
207
219
|
require_paths:
|
208
220
|
- lib
|
@@ -217,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
229
|
- !ruby/object:Gem::Version
|
218
230
|
version: '0'
|
219
231
|
requirements: []
|
220
|
-
rubygems_version: 3.0.3
|
232
|
+
rubygems_version: 3.0.3.1
|
221
233
|
signing_key:
|
222
234
|
specification_version: 4
|
223
235
|
summary: Flexible authentication solution for Rails with Warden
|