devise 4.5.0 → 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 +137 -3
- data/MIT-LICENSE +2 -1
- data/README.md +125 -60
- data/app/controllers/devise/confirmations_controller.rb +1 -0
- data/app/controllers/devise/passwords_controller.rb +3 -2
- data/app/controllers/devise/registrations_controller.rb +26 -8
- data/app/controllers/devise/sessions_controller.rb +1 -1
- data/app/controllers/devise/unlocks_controller.rb +1 -0
- data/app/controllers/devise_controller.rb +3 -2
- data/app/helpers/devise_helper.rb +21 -18
- data/app/mailers/devise/mailer.rb +5 -5
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +2 -2
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +2 -2
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +2 -2
- data/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/app/views/devise/shared/_links.html.erb +8 -8
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +3 -2
- data/lib/devise/controllers/helpers.rb +8 -8
- 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 +29 -7
- data/lib/devise/hooks/csrf_cleaner.rb +6 -1
- data/lib/devise/hooks/lockable.rb +2 -5
- data/lib/devise/hooks/timeoutable.rb +2 -2
- data/lib/devise/mapping.rb +1 -1
- data/lib/devise/models/authenticatable.rb +20 -24
- data/lib/devise/models/confirmable.rb +34 -40
- data/lib/devise/models/database_authenticatable.rb +47 -28
- data/lib/devise/models/lockable.rb +13 -5
- data/lib/devise/models/omniauthable.rb +2 -2
- data/lib/devise/models/recoverable.rb +8 -19
- data/lib/devise/models/registerable.rb +2 -0
- data/lib/devise/models/rememberable.rb +2 -2
- data/lib/devise/models/timeoutable.rb +1 -1
- data/lib/devise/models/trackable.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 +6 -6
- data/lib/devise/strategies/authenticatable.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +3 -0
- data/lib/devise/test/controller_helpers.rb +4 -2
- data/lib/devise/test/integration_helpers.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +34 -11
- data/lib/generators/active_record/devise_generator.rb +21 -6
- data/lib/generators/devise/controllers_generator.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +1 -1
- data/lib/generators/devise/install_generator.rb +1 -5
- data/lib/generators/devise/views_generator.rb +1 -1
- data/lib/generators/templates/README +9 -1
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
- data/lib/generators/templates/devise.rb +37 -14
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -1
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
- metadata +23 -318
- data/.gitignore +0 -10
- data/.travis.yml +0 -69
- data/.yardopts +0 -9
- data/CODE_OF_CONDUCT.md +0 -22
- data/CONTRIBUTING.md +0 -79
- data/Gemfile +0 -39
- data/Gemfile.lock +0 -202
- data/ISSUE_TEMPLATE.md +0 -19
- data/Rakefile +0 -37
- data/bin/test +0 -13
- data/devise.gemspec +0 -28
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-4.1-stable +0 -32
- data/gemfiles/Gemfile.rails-4.1-stable.lock +0 -171
- data/gemfiles/Gemfile.rails-4.2-stable +0 -32
- data/gemfiles/Gemfile.rails-4.2-stable.lock +0 -192
- data/gemfiles/Gemfile.rails-5.0-stable +0 -33
- data/gemfiles/Gemfile.rails-5.0-stable.lock +0 -192
- data/gemfiles/Gemfile.rails-5.2-rc1 +0 -26
- data/gemfiles/Gemfile.rails-5.2-rc1.lock +0 -201
- data/guides/bug_report_templates/integration_test.rb +0 -106
- data/test/controllers/custom_registrations_controller_test.rb +0 -42
- data/test/controllers/custom_strategy_test.rb +0 -66
- data/test/controllers/helper_methods_test.rb +0 -24
- data/test/controllers/helpers_test.rb +0 -318
- data/test/controllers/inherited_controller_i18n_messages_test.rb +0 -53
- data/test/controllers/internal_helpers_test.rb +0 -129
- data/test/controllers/load_hooks_controller_test.rb +0 -21
- data/test/controllers/passwords_controller_test.rb +0 -34
- data/test/controllers/sessions_controller_test.rb +0 -108
- data/test/controllers/url_helpers_test.rb +0 -67
- data/test/delegator_test.rb +0 -21
- data/test/devise_test.rb +0 -109
- data/test/failure_app_test.rb +0 -346
- data/test/generators/active_record_generator_test.rb +0 -130
- data/test/generators/controllers_generator_test.rb +0 -50
- data/test/generators/devise_generator_test.rb +0 -41
- data/test/generators/install_generator_test.rb +0 -26
- data/test/generators/mongoid_generator_test.rb +0 -25
- data/test/generators/views_generator_test.rb +0 -105
- data/test/helpers/devise_helper_test.rb +0 -51
- data/test/integration/authenticatable_test.rb +0 -706
- data/test/integration/confirmable_test.rb +0 -326
- data/test/integration/database_authenticatable_test.rb +0 -110
- data/test/integration/http_authenticatable_test.rb +0 -114
- data/test/integration/lockable_test.rb +0 -242
- data/test/integration/mounted_engine_test.rb +0 -38
- data/test/integration/omniauthable_test.rb +0 -148
- data/test/integration/recoverable_test.rb +0 -349
- data/test/integration/registerable_test.rb +0 -365
- data/test/integration/rememberable_test.rb +0 -219
- data/test/integration/timeoutable_test.rb +0 -186
- data/test/integration/trackable_test.rb +0 -99
- data/test/mailers/confirmation_instructions_test.rb +0 -117
- data/test/mailers/email_changed_test.rb +0 -132
- data/test/mailers/mailer_test.rb +0 -20
- data/test/mailers/reset_password_instructions_test.rb +0 -98
- data/test/mailers/unlock_instructions_test.rb +0 -93
- data/test/mapping_test.rb +0 -136
- data/test/models/authenticatable_test.rb +0 -25
- data/test/models/confirmable_test.rb +0 -549
- data/test/models/database_authenticatable_test.rb +0 -290
- data/test/models/lockable_test.rb +0 -352
- data/test/models/omniauthable_test.rb +0 -9
- data/test/models/recoverable_test.rb +0 -263
- data/test/models/registerable_test.rb +0 -9
- data/test/models/rememberable_test.rb +0 -184
- data/test/models/serializable_test.rb +0 -60
- data/test/models/timeoutable_test.rb +0 -53
- data/test/models/trackable_test.rb +0 -80
- data/test/models/validatable_test.rb +0 -121
- data/test/models_test.rb +0 -155
- data/test/omniauth/config_test.rb +0 -61
- data/test/omniauth/url_helpers_test.rb +0 -53
- data/test/orm/active_record.rb +0 -24
- data/test/orm/mongoid.rb +0 -15
- data/test/parameter_sanitizer_test.rb +0 -105
- data/test/rails_app/Rakefile +0 -6
- data/test/rails_app/app/active_record/admin.rb +0 -8
- data/test/rails_app/app/active_record/shim.rb +0 -4
- data/test/rails_app/app/active_record/user.rb +0 -20
- data/test/rails_app/app/active_record/user_on_engine.rb +0 -9
- data/test/rails_app/app/active_record/user_on_main_app.rb +0 -9
- data/test/rails_app/app/active_record/user_with_validations.rb +0 -12
- data/test/rails_app/app/active_record/user_without_email.rb +0 -10
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -8
- data/test/rails_app/app/controllers/admins_controller.rb +0 -8
- data/test/rails_app/app/controllers/application_controller.rb +0 -13
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +0 -32
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +0 -33
- data/test/rails_app/app/controllers/home_controller.rb +0 -31
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -4
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -4
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -16
- data/test/rails_app/app/controllers/users_controller.rb +0 -33
- data/test/rails_app/app/helpers/application_helper.rb +0 -5
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +0 -5
- data/test/rails_app/app/mailers/users/mailer.rb +0 -5
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +0 -6
- data/test/rails_app/app/mongoid/admin.rb +0 -31
- data/test/rails_app/app/mongoid/shim.rb +0 -25
- data/test/rails_app/app/mongoid/user.rb +0 -50
- data/test/rails_app/app/mongoid/user_on_engine.rb +0 -41
- data/test/rails_app/app/mongoid/user_on_main_app.rb +0 -41
- data/test/rails_app/app/mongoid/user_with_validations.rb +0 -37
- data/test/rails_app/app/mongoid/user_without_email.rb +0 -35
- data/test/rails_app/app/views/admins/index.html.erb +0 -1
- data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/home/index.html.erb +0 -1
- data/test/rails_app/app/views/home/join.html.erb +0 -1
- data/test/rails_app/app/views/home/private.html.erb +0 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
- data/test/rails_app/app/views/layouts/application.html.erb +0 -24
- data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
- data/test/rails_app/app/views/users/index.html.erb +0 -1
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
- data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
- data/test/rails_app/bin/bundle +0 -3
- data/test/rails_app/bin/rails +0 -4
- data/test/rails_app/bin/rake +0 -4
- data/test/rails_app/config/application.rb +0 -48
- data/test/rails_app/config/boot.rb +0 -27
- data/test/rails_app/config/database.yml +0 -18
- data/test/rails_app/config/environment.rb +0 -7
- data/test/rails_app/config/environments/development.rb +0 -32
- data/test/rails_app/config/environments/production.rb +0 -88
- data/test/rails_app/config/environments/test.rb +0 -47
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -9
- data/test/rails_app/config/initializers/devise.rb +0 -187
- data/test/rails_app/config/initializers/inflections.rb +0 -4
- data/test/rails_app/config/initializers/secret_token.rb +0 -5
- data/test/rails_app/config/initializers/session_store.rb +0 -3
- data/test/rails_app/config/routes.rb +0 -128
- data/test/rails_app/config.ru +0 -4
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -77
- data/test/rails_app/db/schema.rb +0 -57
- data/test/rails_app/lib/lazy_load_test_module.rb +0 -5
- data/test/rails_app/lib/shared_admin.rb +0 -23
- data/test/rails_app/lib/shared_user.rb +0 -32
- data/test/rails_app/lib/shared_user_without_email.rb +0 -28
- data/test/rails_app/lib/shared_user_without_omniauth.rb +0 -15
- data/test/rails_app/public/404.html +0 -26
- data/test/rails_app/public/422.html +0 -26
- data/test/rails_app/public/500.html +0 -26
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_test.rb +0 -11
- data/test/routes_test.rb +0 -281
- data/test/secret_key_finder_test.rb +0 -121
- data/test/support/action_controller/record_identifier.rb +0 -12
- data/test/support/assertions.rb +0 -30
- data/test/support/helpers.rb +0 -83
- data/test/support/http_method_compatibility.rb +0 -53
- data/test/support/integration.rb +0 -95
- data/test/support/locale/en.yml +0 -8
- data/test/support/mongoid.yml +0 -6
- data/test/support/webrat/integrations/rails.rb +0 -35
- data/test/test/controller_helpers_test.rb +0 -193
- data/test/test/integration_helpers_test.rb +0 -34
- data/test/test_helper.rb +0 -36
- data/test/test_models.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7640b97ddd188a63e29076d8d94b0a4ebaecc23aad53b8e608b4b1d029818570
|
4
|
+
data.tar.gz: 7e8b512895f0fd73e307bebe494ea3d7d0bd9ecd562b917016b1f7f56d483d2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7cd4534d2abb7ba16353d4f41ea63ed0334eccf68c1357dc37c68b51ad90f1a9cb8544e8f90c2249b2067bdfd0b6c19d245562a1eecef2291ea8705143878ec
|
7
|
+
data.tar.gz: f9bc9ea3a1dfdf86ab79dc47839c79b07fd5613dddfb40022fa508729dded4971dd30055f6f8b901c6a9182513414750825064db278d7865ae7a4576513c08f7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,139 @@
|
|
1
1
|
### Unreleased
|
2
2
|
|
3
|
+
* deprecations
|
4
|
+
* Bring back `Devise.activerecord51?` and deprecate it, in order to avoid breakage with some libraries that apparently relied on it.
|
5
|
+
|
6
|
+
### 4.9.1 - 2023-03-31
|
7
|
+
|
8
|
+
* enhancements
|
9
|
+
* Allow resource class scopes to override the global configuration for `sign_in_after_reset_password` behaviour. [#5429](https://github.com/heartcombo/devise/pull/5429) [@mattr](https://github.com/mattr)
|
10
|
+
* Refactor conditional dirty tracking logic to a centralized module to simplify usage throughout the codebase. [#5575](https://github.com/heartcombo/devise/pull/5575)
|
11
|
+
* Improve support for Devise in apps with Active Record and Mongoid ORMs loaded, so it does not incorrectly uses new Active Record dirty tracking APIs with a Mongoid Devise model. [#5576](https://github.com/heartcombo/devise/pull/5576)
|
12
|
+
|
13
|
+
* bug fixes
|
14
|
+
* Failure app will respond with configured `redirect_status` instead of `error_status` if the recall app returns a redirect status (300..399) [#5573](https://github.com/heartcombo/devise/pull/5573)
|
15
|
+
* Fix frozen string exception in validatable. [#5563](https://github.com/heartcombo/devise/pull/5563) [#5465](https://github.com/heartcombo/devise/pull/5465) [@mameier](https://github.com/mameier)
|
16
|
+
|
17
|
+
### 4.9.0 - 2023-02-17
|
18
|
+
|
19
|
+
* enhancements
|
20
|
+
* Add support for Ruby 3.1/3.2.
|
21
|
+
* Add support for Hotwire + Turbo, default in Rails 7+.
|
22
|
+
* Devise uses the latest `responders` version (v3.1.0 or higher), which allows configuring the status used for validation error responses (`error_status`) and for redirects after POST/PUT/PATCH/DELETE requests (`redirect_status`). For backwards compatibility, Devise keeps `error_status` as `:ok` which returns a `200 OK` response, and `redirect_status` to `:found` which returns a `302 Found` response, but you can configure it to return `422 Unprocessable Entity` and `303 See Other` respectively, to match the behavior expected by Hotwire/Turbo:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
# config/initializers/devise.rb
|
26
|
+
Devise.setup do |config|
|
27
|
+
# ...
|
28
|
+
config.responder.error_status = :unprocessable_entity
|
29
|
+
config.responder.redirect_status = :see_other
|
30
|
+
# ...
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
These configs are already generated by default with new apps, and existing apps may opt-in as described above. Trying to set these with an older version of `responders` will issue a warning and have no effect, so please upgrade the `responders` version if you're upgrading Devise for this integration. Note that these defaults may change in future versions of Devise, to better match the Rails + Hotwire/Turbo defaults across the board.
|
35
|
+
* If you have a custom responder set on your application and expect it to affect Devise as well, you may need to override the Devise responder entirely with `config.responder = MyApplicationResponder`, so that it uses your custom one. The main reason Devise uses a custom responder is to be able to configure the statuses as described above, but you can also change that config on your own responder if you want. Check the `responders` readme for more info on that.
|
36
|
+
* If you have created a custom responder and/or failure app just to customize responses for better Hotwire/Turbo integration, they should no longer be necessary.
|
37
|
+
* `:turbo_stream` is now treated as a navigational format, so it works like HTML navigation when using Turbo. Note: if you relied on `:turbo_stream` to be treated as a non-navigational format before, you can reconfigure your `navigational_formats` in the Devise initializer file to exclude it.
|
38
|
+
* OmniAuth "Sign in with" links were changed to buttons that generate HTML forms with method=POST, instead of using link + method=POST that required rails-ujs to work. Since rails-ujs is no longer the default for new Rails apps, this allows the OmniAuth buttons to work in any scenario, with or without rails-ujs and/or Turbo. This only affects apps that are using the default `devise/shared/_links.html.erb` partial from Devise with OmniAuth enabled.
|
39
|
+
* The "Cancel my account" button was changed to include the `data-turbo-confirm` option, so that it works with both rails-ujs and Turbo by default.
|
40
|
+
* Devise does not provide "sign out" links/buttons in its shared views, but if you're using `sign_out_via` with `:delete` (the default), and are using links with `method: :delete`, those need to be updated with `data: { turbo_method: :delete }` instead for Turbo.
|
41
|
+
* Check [this upgrade guide](https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-[Hotwire-Turbo-integration]) for more detailed information.
|
42
|
+
|
43
|
+
### 4.8.1 - 2021-12-16
|
44
|
+
|
45
|
+
* enhancements
|
46
|
+
* Add support for Rails 7.0. Please note that Turbo integration is not fully supported by Devise yet.
|
47
|
+
|
48
|
+
### 4.8.0 - 2021-04-29
|
49
|
+
|
50
|
+
* enhancements
|
51
|
+
* Devise now enables the upgrade of OmniAuth 2+. Previously Devise would raise an error if you'd try to upgrade. Please note that OmniAuth 2 is considered a security upgrade and recommended to everyone. You can read more about the details (and possible necessary changes to your app as part of the upgrade) in [their release notes](https://github.com/omniauth/omniauth/releases/tag/v2.0.0). [Devise's OmniAuth Overview wiki](https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview) was also updated to cover OmniAuth 2.0 requirements.
|
52
|
+
- Note that the upgrade required Devise shared links that initiate the OmniAuth flow to be changed to `method: :post`, which is now a requirement for OmniAuth, part of the security improvement. If you have copied and customized the Devise shared links partial to your app, or if you have other links in your app that initiate the OmniAuth flow, they will have to be updated to use `method: :post`, or changed to use buttons (e.g. `button_to`) to work with OmniAuth 2. (if you're using links with `method: :post`, make sure your app has `rails-ujs` or `jquery-ujs` included in order for these links to work properly.)
|
53
|
+
- As part of the OmniAuth 2.0 upgrade you might also need to add the [`omniauth-rails_csrf_protection`](https://github.com/cookpad/omniauth-rails_csrf_protection) gem to your app if you don't have it already. (and you don't want to roll your own code to verify requests.) Check the OmniAuth v2 release notes for more info.
|
54
|
+
* Introduce `Lockable#reset_failed_attempts!` model method to reset failed attempts counter to 0 after the user signs in.
|
55
|
+
- This logic existed inside the lockable warden hook and is triggered automatically after the user signs in. The new model method is an extraction to allow you to override it in the application to implement things like switching to a write database if you're using the new multi-DB infrastructure from Rails for example, similar to how it's already possible with `Trackable#update_tracked_fields!`.
|
56
|
+
* Add support for Ruby 3.
|
57
|
+
* Add support for Rails 6.1.
|
58
|
+
* Move CI to GitHub Actions.
|
59
|
+
|
60
|
+
* deprecations
|
61
|
+
* `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` is deprecated in favor of `Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION` (@hanachin)
|
62
|
+
|
63
|
+
### 4.7.3 - 2020-09-20
|
64
|
+
|
65
|
+
* bug fixes
|
66
|
+
* Do not modify `:except` option given to `#serializable_hash`. (by @dpep)
|
67
|
+
* Fix thor deprecation when running the devise generator. (by @deivid-rodriguez)
|
68
|
+
* Fix hanging tests for streaming controllers using Devise. (by @afn)
|
69
|
+
|
70
|
+
### 4.7.2 - 2020-06-10
|
71
|
+
|
72
|
+
* enhancements
|
73
|
+
* Increase default stretches to 12 (by @sergey-alekseev)
|
74
|
+
* Ruby 2.7 support (kwarg warnings removed)
|
75
|
+
|
76
|
+
* bug fixes
|
77
|
+
* Generate scoped views with proper scoped errors partial (by @shobhitic)
|
78
|
+
* Allow to set scoped `already_authenticated` error messages (by @gurgelrenan)
|
79
|
+
|
80
|
+
### 4.7.1 - 2019-09-06
|
81
|
+
|
82
|
+
* bug fixes
|
83
|
+
* Fix an edge case where records with a blank `confirmation_token` could be confirmed (by @tegon)
|
84
|
+
* Fix typo inside `update_needs_confirmation` i18n key (by @lslm)
|
85
|
+
|
86
|
+
### 4.7.0 - 2019-08-19
|
87
|
+
|
88
|
+
* enhancements
|
89
|
+
* Support Rails 6.0
|
90
|
+
* Update CI to rails 6.0.0.beta3 (by @tunnes)
|
91
|
+
* refactor method name to be more consistent (by @saiqulhaq)
|
92
|
+
* Fix rails 6.0.rc1 email uniqueness validation deprecation warning (by @Vasfed)
|
93
|
+
|
94
|
+
* bug fixes
|
95
|
+
* Add `autocomplete="new-password"` to `password_confirmation` fields (by @ferrl)
|
96
|
+
* Fix rails_51_and_up? method for Rails 6.rc1 (by @igorkasyanchuk)
|
97
|
+
|
98
|
+
### 4.6.2 - 2019-03-26
|
99
|
+
|
100
|
+
* bug fixes
|
101
|
+
* Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/heartcombo/devise/issues/5033#issuecomment-476386275 (by @mracos)
|
102
|
+
|
103
|
+
### 4.6.1 - 2019-02-11
|
104
|
+
|
105
|
+
* bug fixes
|
106
|
+
* Check if `root_path` is defined with `#respond_to?` instead of `#present` (by @tegon)
|
107
|
+
|
108
|
+
### 4.6.0 - 2019-02-07
|
109
|
+
|
110
|
+
* enhancements
|
111
|
+
* Allow to skip email and password change notifications (by @iorme1)
|
112
|
+
* Include the use of `nil` for `allow_unconfirmed_access_for` in the docs (by @joaumg)
|
113
|
+
* Ignore useless files into the `.gem` file (by @huacnlee)
|
114
|
+
* Explain the code that prevents enumeration attacks inside `Devise::Strategies::DatabaseAuthenticatable` (by @tegon)
|
115
|
+
* Refactor the `devise_error_messages!` helper to render a partial (by @prograhamer)
|
116
|
+
* Add an option (`Devise.sign_in_after_change_password`) to not automatically sign in a user after changing a password (by @knjko)
|
117
|
+
|
118
|
+
* bug fixes
|
119
|
+
* Fix missing comma in Simple Form generator (by @colinross)
|
120
|
+
* Fix error with migration generator in Rails 6 (by @oystersauce8)
|
121
|
+
* Set `encrypted_password` to `nil` when `password` is set to `nil` (by @sivagollapalli)
|
122
|
+
* Consider whether the request supports flash messages inside `Devise::Controllers::Helpers#is_flashing_format?` (by @colinross)
|
123
|
+
* Fix typo inside `Devise::Generators::ControllersGenerator` (by @kopylovvlad)
|
124
|
+
* Sanitize parameters inside `Devise::Models::Authenticatable#find_or_initialize_with_errors` (by @rlue)
|
125
|
+
* `#after_database_authentication` callback was not called after authentication on password reset (by @kanmaniselvan)
|
126
|
+
* Fix corner case when `#confirmation_period_valid?` was called at the same second as `confirmation_sent_at` was set. Mostly true for date types that only have second precisions. (by @stanhu)
|
127
|
+
* Fix unclosed `li` tag in `error_messages` partial (by @mracos)
|
128
|
+
* Fix Routes issue when devise engine is mounted in another engine on Rails versions lower than 5.1 (by @a-barbieri)
|
129
|
+
* Make `#increment_failed_attempts` concurrency safe (by @tegon)
|
130
|
+
* Apply Test Helper fix to Rails 6.0 as well as 5.x (by @matthewrudy)
|
131
|
+
|
132
|
+
|
133
|
+
* deprecations
|
134
|
+
* The second argument of `DatabaseAuthenticatable`'s `#update_with_password` and `#update_without_password` is deprecated and will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it from your code. (by @ihatov08)
|
135
|
+
* The `DeviseHelper.devise_error_messages!` is deprecated and will be removed in the next major version. Use the `devise/shared/error_messages` partial instead. (by @mracos)
|
136
|
+
|
3
137
|
### 4.5.0 - 2018-08-15
|
4
138
|
|
5
139
|
* enhancements
|
@@ -11,7 +145,7 @@
|
|
11
145
|
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
|
12
146
|
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
|
13
147
|
* Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
|
14
|
-
* Update `simple_form` templates with changes from https://github.com/
|
148
|
+
* Update `simple_form` templates with changes from https://github.com/heartcombo/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/heartcombo/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
|
15
149
|
* Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
|
16
150
|
|
17
151
|
* bug fixes
|
@@ -255,8 +389,8 @@ configured (by @joshpencheon)
|
|
255
389
|
end
|
256
390
|
```
|
257
391
|
|
258
|
-
You can check more examples and explanations on the [README section](
|
392
|
+
You can check more examples and explanations on the [README section](README.md#strong-parameters)
|
259
393
|
and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
|
260
394
|
|
261
|
-
Please check [3-stable](https://github.com/
|
395
|
+
Please check [3-stable](https://github.com/heartcombo/devise/blob/3-stable/CHANGELOG.md)
|
262
396
|
for previous changes.
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2020-2023 Rafael França, Leonardo Tegon, Carlos Antônio da Silva.
|
2
|
+
Copyright 2009-2019 Plataformatec.
|
2
3
|
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
5
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,11 +1,4 @@
|
|
1
|
-
![Devise Logo](https://raw.github.com/
|
2
|
-
|
3
|
-
By [Plataformatec](http://plataformatec.com.br/).
|
4
|
-
|
5
|
-
[![Build Status](https://api.travis-ci.org/plataformatec/devise.svg?branch=master)](http://travis-ci.org/plataformatec/devise)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.svg)](https://codeclimate.com/github/plataformatec/devise)
|
7
|
-
|
8
|
-
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
|
1
|
+
![Devise Logo](https://raw.github.com/heartcombo/devise/main/devise.png)
|
9
2
|
|
10
3
|
Devise is a flexible authentication solution for Rails based on Warden. It:
|
11
4
|
|
@@ -16,16 +9,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
|
16
9
|
|
17
10
|
It's composed of 10 modules:
|
18
11
|
|
19
|
-
* [Database Authenticatable](http://www.rubydoc.info/github/
|
20
|
-
* [Omniauthable](http://www.rubydoc.info/github/
|
21
|
-
* [Confirmable](http://www.rubydoc.info/github/
|
22
|
-
* [Recoverable](http://www.rubydoc.info/github/
|
23
|
-
* [Registerable](http://www.rubydoc.info/github/
|
24
|
-
* [Rememberable](http://www.rubydoc.info/github/
|
25
|
-
* [Trackable](http://www.rubydoc.info/github/
|
26
|
-
* [Timeoutable](http://www.rubydoc.info/github/
|
27
|
-
* [Validatable](http://www.rubydoc.info/github/
|
28
|
-
* [Lockable](http://www.rubydoc.info/github/
|
12
|
+
* [Database Authenticatable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
13
|
+
* [Omniauthable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
14
|
+
* [Confirmable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
15
|
+
* [Recoverable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
16
|
+
* [Registerable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
17
|
+
* [Rememberable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
18
|
+
* [Trackable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
19
|
+
* [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
20
|
+
* [Validatable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
21
|
+
* [Lockable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
29
22
|
|
30
23
|
## Table of Contents
|
31
24
|
|
@@ -56,8 +49,8 @@ It's composed of 10 modules:
|
|
56
49
|
- [ActiveJob Integration](#activejob-integration)
|
57
50
|
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
|
58
51
|
- [Other ORMs](#other-orms)
|
52
|
+
- [Rails API mode](#rails-api-mode)
|
59
53
|
- [Additional information](#additional-information)
|
60
|
-
- [Heroku](#heroku)
|
61
54
|
- [Warden](#warden)
|
62
55
|
- [Contributors](#contributors)
|
63
56
|
- [License](#license)
|
@@ -72,15 +65,15 @@ It's composed of 10 modules:
|
|
72
65
|
|
73
66
|
The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
|
74
67
|
|
75
|
-
https://github.com/
|
68
|
+
https://github.com/heartcombo/devise/wiki
|
76
69
|
|
77
70
|
### Bug reports
|
78
71
|
|
79
72
|
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
|
80
73
|
|
81
|
-
https://github.com/
|
74
|
+
https://github.com/heartcombo/devise/wiki/Bug-reports
|
82
75
|
|
83
|
-
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to
|
76
|
+
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
|
84
77
|
|
85
78
|
### StackOverflow and Mailing List
|
86
79
|
|
@@ -96,7 +89,7 @@ https://groups.google.com/group/plataformatec-devise
|
|
96
89
|
|
97
90
|
You can view the Devise documentation in RDoc format here:
|
98
91
|
|
99
|
-
http://rubydoc.info/github/
|
92
|
+
http://rubydoc.info/github/heartcombo/devise/main/frames
|
100
93
|
|
101
94
|
If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
|
102
95
|
|
@@ -104,26 +97,26 @@ If you need to use Devise with previous versions of Rails, you can always run "g
|
|
104
97
|
|
105
98
|
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
|
106
99
|
|
107
|
-
https://github.com/
|
100
|
+
https://github.com/heartcombo/devise/wiki/Example-Applications
|
108
101
|
|
109
102
|
### Extensions
|
110
103
|
|
111
104
|
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
|
112
105
|
|
113
|
-
https://github.com/
|
106
|
+
https://github.com/heartcombo/devise/wiki/Extensions
|
114
107
|
|
115
108
|
### Contributing
|
116
109
|
|
117
110
|
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
|
118
111
|
|
119
|
-
https://github.com/
|
112
|
+
https://github.com/heartcombo/devise/wiki/Contributing
|
120
113
|
|
121
114
|
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`.
|
122
115
|
Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`.
|
123
116
|
|
124
117
|
### DEVISE_ORM
|
125
|
-
Since Devise
|
126
|
-
The default value of `DEVISE_ORM` is `active_record`. To run the tests for
|
118
|
+
Since Devise supports both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
|
119
|
+
The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
|
127
120
|
```
|
128
121
|
DEVISE_ORM=mongoid bin/test
|
129
122
|
|
@@ -135,7 +128,7 @@ Please note that the command output will show the variable value being used.
|
|
135
128
|
|
136
129
|
### BUNDLE_GEMFILE
|
137
130
|
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
|
138
|
-
Inside the [gemfiles](https://github.com/
|
131
|
+
Inside the [gemfiles](https://github.com/heartcombo/devise/tree/main/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
|
139
132
|
For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
|
140
133
|
```bash
|
141
134
|
rbenv shell 2.4.2 # or rvm use 2.4.2
|
@@ -149,13 +142,31 @@ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
|
|
149
142
|
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
|
150
143
|
```
|
151
144
|
|
145
|
+
### Running tests
|
146
|
+
Devise uses [Mini Test](https://github.com/seattlerb/minitest) as test framework.
|
147
|
+
|
148
|
+
* Running all tests:
|
149
|
+
```bash
|
150
|
+
bin/test
|
151
|
+
```
|
152
|
+
|
153
|
+
* Running tests for an specific file:
|
154
|
+
```bash
|
155
|
+
bin/test test/models/trackable_test.rb
|
156
|
+
```
|
157
|
+
|
158
|
+
* Running a specific test given a regex:
|
159
|
+
```bash
|
160
|
+
bin/test test/models/trackable_test.rb:16
|
161
|
+
```
|
162
|
+
|
152
163
|
## Starting with Rails?
|
153
164
|
|
154
|
-
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch.
|
165
|
+
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Here's a few resources that should help you get started:
|
155
166
|
|
156
167
|
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
|
157
|
-
* Ryan Bates'
|
158
|
-
* Codecademy's Ruby on Rails: Authentication and Authorization:
|
168
|
+
* Ryan Bates' Railscasts: http://railscasts.com/episodes/250-authentication-from-scratch and http://railscasts.com/episodes/250-authentication-from-scratch-revised
|
169
|
+
* Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
|
159
170
|
|
160
171
|
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
|
161
172
|
|
@@ -251,16 +262,16 @@ member_session
|
|
251
262
|
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
|
252
263
|
|
253
264
|
```ruby
|
254
|
-
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches:
|
265
|
+
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
|
255
266
|
```
|
256
267
|
|
257
268
|
Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
|
258
269
|
|
259
270
|
### Strong Parameters
|
260
271
|
|
261
|
-
|
272
|
+
The Parameter Sanitizer API has changed for Devise 4 :warning:
|
262
273
|
|
263
|
-
*For previous Devise versions see https://github.com/
|
274
|
+
*For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
|
264
275
|
|
265
276
|
When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
|
266
277
|
|
@@ -270,7 +281,7 @@ There are just three actions in Devise that allow any set of parameters to be pa
|
|
270
281
|
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
|
271
282
|
* `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
|
272
283
|
|
273
|
-
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before
|
284
|
+
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before action in your `ApplicationController`:
|
274
285
|
|
275
286
|
```ruby
|
276
287
|
class ApplicationController < ActionController::Base
|
@@ -298,7 +309,7 @@ class ApplicationController < ActionController::Base
|
|
298
309
|
end
|
299
310
|
```
|
300
311
|
|
301
|
-
Devise allows you to completely change Devise defaults or invoke custom
|
312
|
+
Devise allows you to completely change Devise defaults or invoke custom behavior by passing a block:
|
302
313
|
|
303
314
|
To permit simple scalar values for username and email, use this
|
304
315
|
|
@@ -371,7 +382,7 @@ $ rails generate devise:views users
|
|
371
382
|
```
|
372
383
|
|
373
384
|
If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
|
374
|
-
you can pass a list of
|
385
|
+
you can pass a list of views to the generator with the `-v` flag.
|
375
386
|
|
376
387
|
```console
|
377
388
|
$ rails generate devise:views -v registrations confirmations
|
@@ -399,7 +410,7 @@ If the customization at the views level is not enough, you can customize each co
|
|
399
410
|
...
|
400
411
|
end
|
401
412
|
```
|
402
|
-
|
413
|
+
Use the `-c` flag to specify one or more controllers, for example: `rails generate devise:controllers users -c sessions`)
|
403
414
|
|
404
415
|
2. Tell the router to use this controller:
|
405
416
|
|
@@ -407,7 +418,7 @@ If the customization at the views level is not enough, you can customize each co
|
|
407
418
|
devise_for :users, controllers: { sessions: 'users/sessions' }
|
408
419
|
```
|
409
420
|
|
410
|
-
3.
|
421
|
+
3. Recommended but not required: copy (or move) the views from `devise/sessions` to `users/sessions`. Rails will continue using the views from `devise/sessions` due to inheritance if you skip this step, but having the views matching the controller(s) keeps things consistent.
|
411
422
|
|
412
423
|
4. Finally, change or extend the desired controller actions.
|
413
424
|
|
@@ -421,7 +432,7 @@ If the customization at the views level is not enough, you can customize each co
|
|
421
432
|
end
|
422
433
|
```
|
423
434
|
|
424
|
-
Or you can simply add new
|
435
|
+
Or you can simply add new behavior to it:
|
425
436
|
|
426
437
|
```ruby
|
427
438
|
class Users::SessionsController < Devise::SessionsController
|
@@ -445,7 +456,7 @@ Devise also ships with default routes. If you need to customize them, you should
|
|
445
456
|
devise_for :users, path: 'auth', path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
|
446
457
|
```
|
447
458
|
|
448
|
-
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/
|
459
|
+
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/main/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
|
449
460
|
|
450
461
|
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
|
451
462
|
|
@@ -463,6 +474,36 @@ Please note: You will still need to add `devise_for` in your routes in order to
|
|
463
474
|
devise_for :users, skip: :all
|
464
475
|
```
|
465
476
|
|
477
|
+
### Hotwire/Turbo
|
478
|
+
|
479
|
+
Devise integrates with Hotwire/Turbo by treating such requests as navigational, and configuring certain responses for errors and redirects to match the expected behavior. New apps are generated with the following response configuration by default, and existing apps may opt-in by adding the config to their Devise initializers:
|
480
|
+
|
481
|
+
```ruby
|
482
|
+
Devise.setup do |config|
|
483
|
+
# ...
|
484
|
+
# When using Devise with Hotwire/Turbo, the http status for error responses
|
485
|
+
# and some redirects must match the following. The default in Devise for existing
|
486
|
+
# apps is `200 OK` and `302 Found respectively`, but new apps are generated with
|
487
|
+
# these new defaults that match Hotwire/Turbo behavior.
|
488
|
+
# Note: These might become the new default in future versions of Devise.
|
489
|
+
config.responder.error_status = :unprocessable_entity
|
490
|
+
config.responder.redirect_status = :see_other
|
491
|
+
end
|
492
|
+
```
|
493
|
+
|
494
|
+
**Important**: these custom responses require the `responders` gem version to be `3.1.0` or higher, please make sure you update it if you're going to use this configuration. Check [this upgrade guide](https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-[Hotwire-Turbo-integration]) for more info.
|
495
|
+
|
496
|
+
_Note_: the above statuses configuration may become the default for Devise in a future release.
|
497
|
+
|
498
|
+
There are a couple other changes you might need to make in your app to work with Hotwire/Turbo, if you're migrating from rails-ujs:
|
499
|
+
|
500
|
+
* The `data-confirm` option that adds a confirmation modal to buttons/forms before submission needs to change to `data-turbo-confirm`, so that Turbo handles those appropriately.
|
501
|
+
* The `data-method` option that sets the request method for link submissions needs to change to `data-turbo-method`. This is not necessary for `button_to` or `form`s since Turbo can handle those.
|
502
|
+
|
503
|
+
If you're setting up Devise to sign out via `:delete`, and you're using links (instead of buttons wrapped in a form) to sign out with the `method: :delete` option, they will need to be updated as described above. (Devise does not provide sign out links/buttons in its shared views.)
|
504
|
+
|
505
|
+
Make sure to inspect your views looking for those, and change appropriately.
|
506
|
+
|
466
507
|
### I18n
|
467
508
|
|
468
509
|
Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
|
@@ -501,7 +542,7 @@ en:
|
|
501
542
|
|
502
543
|
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
|
503
544
|
|
504
|
-
https://github.com/
|
545
|
+
https://github.com/heartcombo/devise/wiki/I18n
|
505
546
|
|
506
547
|
Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
|
507
548
|
|
@@ -513,15 +554,21 @@ cases/specs.
|
|
513
554
|
|
514
555
|
### Controller tests
|
515
556
|
|
516
|
-
Controller tests require that you include `Devise::Test::
|
557
|
+
Controller tests require that you include `Devise::Test::IntegrationHelpers` on
|
517
558
|
your test case or its parent `ActionController::TestCase` superclass.
|
518
|
-
For Rails 5, include `Devise::Test::
|
519
|
-
for controller tests
|
559
|
+
For Rails versions prior to 5, include `Devise::Test::ControllerHelpers` instead, since the superclass
|
560
|
+
for controller tests was changed to ActionDispatch::IntegrationTest
|
520
561
|
(for more details, see the [Integration tests](#integration-tests) section).
|
521
562
|
|
522
563
|
```ruby
|
523
564
|
class PostsControllerTest < ActionController::TestCase
|
524
|
-
include Devise::Test::
|
565
|
+
include Devise::Test::IntegrationHelpers # Rails >= 5
|
566
|
+
end
|
567
|
+
```
|
568
|
+
|
569
|
+
```ruby
|
570
|
+
class PostsControllerTest < ActionController::TestCase
|
571
|
+
include Devise::Test::ControllerHelpers # Rails < 5
|
525
572
|
end
|
526
573
|
```
|
527
574
|
|
@@ -601,7 +648,7 @@ are executed in your tests.
|
|
601
648
|
|
602
649
|
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
|
603
650
|
|
604
|
-
* https://github.com/
|
651
|
+
* https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
|
605
652
|
|
606
653
|
### OmniAuth
|
607
654
|
|
@@ -613,7 +660,7 @@ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
|
613
660
|
|
614
661
|
You can read more about OmniAuth support in the wiki:
|
615
662
|
|
616
|
-
* https://github.com/
|
663
|
+
* https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
|
617
664
|
|
618
665
|
### Configuring multiple models
|
619
666
|
|
@@ -660,12 +707,12 @@ end
|
|
660
707
|
|
661
708
|
### Password reset tokens and Rails logs
|
662
709
|
|
663
|
-
If you enable the [Recoverable](http://rubydoc.info/github/
|
710
|
+
If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/main/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
|
664
711
|
|
665
712
|
1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
|
666
713
|
2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
|
667
714
|
|
668
|
-
Rails sets the production logger level to
|
715
|
+
Rails sets the production logger level to INFO by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
|
669
716
|
|
670
717
|
```ruby
|
671
718
|
config.log_level = :warn
|
@@ -676,32 +723,50 @@ config.log_level = :warn
|
|
676
723
|
|
677
724
|
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
|
678
725
|
|
679
|
-
|
726
|
+
### Rails API Mode
|
727
|
+
|
728
|
+
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). Devise is _somewhat_ able to handle applications that are built in this mode without additional modifications in the sense that it should not raise exceptions and the like. But some issues may still arise during `development`/`testing`, as we still don't know the full extent of this compatibility. (For more information, see [issue #4947](https://github.com/heartcombo/devise/issues/4947/))
|
729
|
+
|
730
|
+
#### Supported Authentication Strategies
|
731
|
+
API-only applications don't support browser-based authentication via cookies, which is devise's default. Yet, devise can still provide authentication out of the box in those cases with the `http_authenticatable` strategy, which uses HTTP Basic Auth and authenticates the user on each request. (For more info, see this wiki article for [How To: Use HTTP Basic Authentication](https://github.com/heartcombo/devise/wiki/How-To:-Use-HTTP-Basic-Authentication))
|
732
|
+
|
733
|
+
The devise default for HTTP Auth is disabled, so it will need to be enabled in the devise initializer for the database strategy:
|
734
|
+
|
735
|
+
```ruby
|
736
|
+
config.http_authenticatable = [:database]
|
737
|
+
```
|
680
738
|
|
681
|
-
|
739
|
+
This restriction does not limit you from implementing custom warden strategies, either in your application or via gem-based extensions for devise.
|
740
|
+
A common authentication strategy for APIs is token-based authentication. For more information on extending devise to support this type of authentication and others, see the wiki article for [Simple Token Authentication Examples and alternatives](https://github.com/heartcombo/devise/wiki/How-To:-Simple-Token-Authentication-Example#alternatives) or this blog post on [Custom authentication methods with Devise](http://blog.plataformatec.com.br/2019/01/custom-authentication-methods-with-devise/).
|
682
741
|
|
683
|
-
|
742
|
+
#### Testing
|
743
|
+
API Mode changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
|
684
744
|
|
685
745
|
```ruby
|
686
|
-
config.
|
746
|
+
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
|
747
|
+
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
|
687
748
|
```
|
688
749
|
|
689
|
-
|
750
|
+
For a deeper understanding of this, review [this issue](https://github.com/heartcombo/devise/issues/4696).
|
751
|
+
|
752
|
+
Additionally be mindful that without views supported, some email-based flows from Confirmable, Recoverable and Lockable are not supported directly at this time.
|
753
|
+
|
754
|
+
## Additional information
|
690
755
|
|
691
756
|
### Warden
|
692
757
|
|
693
758
|
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
|
694
759
|
|
695
|
-
https://github.com/
|
760
|
+
https://github.com/wardencommunity/warden
|
696
761
|
|
697
762
|
### Contributors
|
698
763
|
|
699
764
|
We have a long list of valued contributors. Check them all at:
|
700
765
|
|
701
|
-
https://github.com/
|
766
|
+
https://github.com/heartcombo/devise/graphs/contributors
|
702
767
|
|
703
768
|
## License
|
704
769
|
|
705
|
-
MIT License. Copyright 2009-
|
770
|
+
MIT License. Copyright 2020-2023 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
|
706
771
|
|
707
|
-
|
772
|
+
The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
|
@@ -27,6 +27,7 @@ class Devise::ConfirmationsController < DeviseController
|
|
27
27
|
set_flash_message!(:notice, :confirmed)
|
28
28
|
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
|
29
29
|
else
|
30
|
+
# TODO: use `error_status` when the default changes to `:unprocessable_entity`.
|
30
31
|
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
31
32
|
end
|
32
33
|
end
|
@@ -36,9 +36,10 @@ class Devise::PasswordsController < DeviseController
|
|
36
36
|
|
37
37
|
if resource.errors.empty?
|
38
38
|
resource.unlock_access! if unlockable?(resource)
|
39
|
-
if
|
39
|
+
if resource_class.sign_in_after_reset_password
|
40
40
|
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
41
41
|
set_flash_message!(:notice, flash_message)
|
42
|
+
resource.after_database_authentication
|
42
43
|
sign_in(resource_name, resource)
|
43
44
|
else
|
44
45
|
set_flash_message!(:notice, :updated_not_active)
|
@@ -52,7 +53,7 @@ class Devise::PasswordsController < DeviseController
|
|
52
53
|
|
53
54
|
protected
|
54
55
|
def after_resetting_password_path_for(resource)
|
55
|
-
|
56
|
+
resource_class.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
|
56
57
|
end
|
57
58
|
|
58
59
|
# The path used after sending reset password instructions
|