devise 4.7.1 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -4
  3. data/MIT-LICENSE +2 -1
  4. data/README.md +68 -61
  5. data/app/controllers/devise_controller.rb +2 -2
  6. data/app/helpers/devise_helper.rb +18 -6
  7. data/app/mailers/devise/mailer.rb +5 -5
  8. data/app/views/devise/shared/_links.html.erb +1 -1
  9. data/config/locales/en.yml +2 -2
  10. data/lib/devise.rb +1 -5
  11. data/lib/devise/controllers/helpers.rb +7 -7
  12. data/lib/devise/controllers/sign_in_out.rb +6 -4
  13. data/lib/devise/controllers/url_helpers.rb +1 -1
  14. data/lib/devise/failure_app.rb +2 -3
  15. data/lib/devise/hooks/lockable.rb +2 -5
  16. data/lib/devise/hooks/timeoutable.rb +2 -2
  17. data/lib/devise/mapping.rb +1 -1
  18. data/lib/devise/models/authenticatable.rb +12 -7
  19. data/lib/devise/models/confirmable.rb +2 -2
  20. data/lib/devise/models/database_authenticatable.rb +5 -1
  21. data/lib/devise/models/lockable.rb +10 -2
  22. data/lib/devise/models/recoverable.rb +2 -2
  23. data/lib/devise/models/rememberable.rb +1 -1
  24. data/lib/devise/models/trackable.rb +1 -1
  25. data/lib/devise/omniauth.rb +2 -5
  26. data/lib/devise/rails/deprecated_constant_accessor.rb +39 -0
  27. data/lib/devise/rails/routes.rb +4 -4
  28. data/lib/devise/test/controller_helpers.rb +3 -1
  29. data/lib/devise/test/integration_helpers.rb +1 -1
  30. data/lib/devise/version.rb +1 -1
  31. data/lib/generators/active_record/devise_generator.rb +17 -2
  32. data/lib/generators/devise/devise_generator.rb +1 -1
  33. data/lib/generators/devise/install_generator.rb +1 -5
  34. data/lib/generators/devise/views_generator.rb +1 -1
  35. data/lib/generators/templates/README +9 -1
  36. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
  37. data/lib/generators/templates/devise.rb +15 -3
  38. metadata +9 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dc5ab8b0dc2a902bcf6f66b156b87cdb5348a336f05fb8605b6db1d1f688bc5
4
- data.tar.gz: 3be07eb3511c19857e9ddd2071b469833ac88d5c780c0a3c831c94523252663b
3
+ metadata.gz: 197ce185bf22b8dc45c17a615895b60e6b788360113c37d99a116db868197309
4
+ data.tar.gz: 8e3fa67c5bcd6c05ac3011e0b35f0cda57596ae74c2affceab84cab1da3aeb58
5
5
  SHA512:
6
- metadata.gz: 599ee2531bd66335b49e7282d2af71be9e02594fc36733ec3c8f96110a256ee918e45a56c88640558b16e943a599881435cdd0dbaa2029636d830364cfbcfeb4
7
- data.tar.gz: e785db9c81e1275f283896d604124067b67685bced32267a75f0205f39d98a0985d68d40933859e31196cd773ccf260841cf1663a4ee9dcaab9c397af2f1c1b2
6
+ metadata.gz: 8d3f76d9e898d36dc6eb4db5d5b098b76d339aeadac014c772b7097dc6a730a7577049bd00ea7a073beead47454edb91d24fe73b50e90af3555cc5e83886902f
7
+ data.tar.gz: 84cbafa77c70de3c204dfdf19e4ce53ac05796eaf959bba4d4909d0c91686baa6da61f732e13bce0892d8932af375d2b81340f6bd1047384f15325f8a24011e0
data/CHANGELOG.md CHANGED
@@ -1,4 +1,36 @@
1
- ### Unreleased
1
+ ### unreleased
2
+
3
+ ### 4.8.0 - 2021-04-29
4
+
5
+ * enhancements
6
+ * 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.
7
+ - 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.)
8
+ - 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.
9
+ * Introduce `Lockable#reset_failed_attempts!` model method to reset failed attempts counter to 0 after the user signs in.
10
+ - 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!`.
11
+ * Add support for Ruby 3.
12
+ * Add support for Rails 6.1.
13
+ * Move CI to GitHub Actions.
14
+
15
+ * deprecations
16
+ * `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` is deprecated in favor of `Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION` (@hanachin)
17
+
18
+ ### 4.7.3 - 2020-09-20
19
+
20
+ * bug fixes
21
+ * Do not modify `:except` option given to `#serializable_hash`. (by @dpep)
22
+ * Fix thor deprecation when running the devise generator. (by @deivid-rodriguez)
23
+ * Fix hanging tests for streaming controllers using Devise. (by @afn)
24
+
25
+ ### 4.7.2 - 2020-06-10
26
+
27
+ * enhancements
28
+ * Increase default stretches to 12 (by @sergey-alekseev)
29
+ * Ruby 2.7 support (kwarg warnings removed)
30
+
31
+ * bug fixes
32
+ * Generate scoped views with proper scoped errors partial (by @shobhitic)
33
+ * Allow to set scoped `already_authenticated` error messages (by @gurgelrenan)
2
34
 
3
35
  ### 4.7.1 - 2019-09-06
4
36
 
@@ -21,7 +53,7 @@
21
53
  ### 4.6.2 - 2019-03-26
22
54
 
23
55
  * bug fixes
24
- * 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/plataformatec/devise/issues/5033#issuecomment-476386275 (by @mracos)
56
+ * 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)
25
57
 
26
58
  ### 4.6.1 - 2019-02-11
27
59
 
@@ -68,7 +100,7 @@
68
100
  * Add `autocomplete="new-password"` to new password fields (by @gssbzn)
69
101
  * Add `autocomplete="current-password"` to current password fields (by @gssbzn)
70
102
  * Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
71
- * Update `simple_form` templates with changes from https://github.com/plataformatec/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/plataformatec/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
103
+ * Update `simple_form` templates with changes from https://github.com/heartcombo/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/heartcombo/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
72
104
  * Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
73
105
 
74
106
  * bug fixes
@@ -315,5 +347,5 @@ configured (by @joshpencheon)
315
347
  You can check more examples and explanations on the [README section](README.md#strong-parameters)
316
348
  and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
317
349
 
318
- Please check [3-stable](https://github.com/plataformatec/devise/blob/3-stable/CHANGELOG.md)
350
+ Please check [3-stable](https://github.com/heartcombo/devise/blob/3-stable/CHANGELOG.md)
319
351
  for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
1
+ Copyright 2020 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,6 @@
1
- ![Devise Logo](https://raw.github.com/plataformatec/devise/master/devise.png)
1
+ ![Devise Logo](https://raw.github.com/heartcombo/devise/master/devise.png)
2
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/).
3
+ [![Code Climate](https://codeclimate.com/github/heartcombo/devise.svg)](https://codeclimate.com/github/heartcombo/devise)
9
4
 
10
5
  Devise is a flexible authentication solution for Rails based on Warden. It:
11
6
 
@@ -16,16 +11,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
16
11
 
17
12
  It's composed of 10 modules:
18
13
 
19
- * [Database Authenticatable](http://www.rubydoc.info/github/plataformatec/devise/master/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.
20
- * [Omniauthable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
21
- * [Confirmable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
22
- * [Recoverable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
23
- * [Registerable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
24
- * [Rememberable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
25
- * [Trackable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
26
- * [Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
27
- * [Validatable](http://www.rubydoc.info/github/plataformatec/devise/master/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.
28
- * [Lockable](http://www.rubydoc.info/github/plataformatec/devise/master/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.
14
+ * [Database Authenticatable](http://www.rubydoc.info/github/heartcombo/devise/master/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.
15
+ * [Omniauthable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
16
+ * [Confirmable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
17
+ * [Recoverable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
18
+ * [Registerable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
19
+ * [Rememberable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
20
+ * [Trackable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
21
+ * [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
22
+ * [Validatable](http://www.rubydoc.info/github/heartcombo/devise/master/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.
23
+ * [Lockable](http://www.rubydoc.info/github/heartcombo/devise/master/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
24
 
30
25
  ## Table of Contents
31
26
 
@@ -58,7 +53,6 @@ It's composed of 10 modules:
58
53
  - [Other ORMs](#other-orms)
59
54
  - [Rails API mode](#rails-api-mode)
60
55
  - [Additional information](#additional-information)
61
- - [Heroku](#heroku)
62
56
  - [Warden](#warden)
63
57
  - [Contributors](#contributors)
64
58
  - [License](#license)
@@ -73,15 +67,15 @@ It's composed of 10 modules:
73
67
 
74
68
  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:
75
69
 
76
- https://github.com/plataformatec/devise/wiki
70
+ https://github.com/heartcombo/devise/wiki
77
71
 
78
72
  ### Bug reports
79
73
 
80
74
  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:
81
75
 
82
- https://github.com/plataformatec/devise/wiki/Bug-reports
76
+ https://github.com/heartcombo/devise/wiki/Bug-reports
83
77
 
84
- If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
78
+ If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
85
79
 
86
80
  ### StackOverflow and Mailing List
87
81
 
@@ -97,7 +91,7 @@ https://groups.google.com/group/plataformatec-devise
97
91
 
98
92
  You can view the Devise documentation in RDoc format here:
99
93
 
100
- http://rubydoc.info/github/plataformatec/devise/master/frames
94
+ http://rubydoc.info/github/heartcombo/devise/master/frames
101
95
 
102
96
  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.
103
97
 
@@ -105,26 +99,26 @@ If you need to use Devise with previous versions of Rails, you can always run "g
105
99
 
106
100
  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:
107
101
 
108
- https://github.com/plataformatec/devise/wiki/Example-Applications
102
+ https://github.com/heartcombo/devise/wiki/Example-Applications
109
103
 
110
104
  ### Extensions
111
105
 
112
106
  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:
113
107
 
114
- https://github.com/plataformatec/devise/wiki/Extensions
108
+ https://github.com/heartcombo/devise/wiki/Extensions
115
109
 
116
110
  ### Contributing
117
111
 
118
112
  We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
119
113
 
120
- https://github.com/plataformatec/devise/wiki/Contributing
114
+ https://github.com/heartcombo/devise/wiki/Contributing
121
115
 
122
116
  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`.
123
117
  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`.
124
118
 
125
119
  ### DEVISE_ORM
126
- Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
127
- The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`:
120
+ Since Devise supports both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
121
+ The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
128
122
  ```
129
123
  DEVISE_ORM=mongoid bin/test
130
124
 
@@ -136,7 +130,7 @@ Please note that the command output will show the variable value being used.
136
130
 
137
131
  ### BUNDLE_GEMFILE
138
132
  We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
139
- Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/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 on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
133
+ Inside the [gemfiles](https://github.com/heartcombo/devise/tree/master/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.
140
134
  For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
141
135
  ```bash
142
136
  rbenv shell 2.4.2 # or rvm use 2.4.2
@@ -170,10 +164,10 @@ bin/test test/models/trackable_test.rb:16
170
164
 
171
165
  ## Starting with Rails?
172
166
 
173
- 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. Today, we have three resources that should help you get started:
167
+ 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:
174
168
 
175
169
  * Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
176
- * Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
170
+ * Ryan Bates' Railscasts: http://railscasts.com/episodes/250-authentication-from-scratch and http://railscasts.com/episodes/250-authentication-from-scratch-revised
177
171
  * Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
178
172
 
179
173
  Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
@@ -270,16 +264,16 @@ member_session
270
264
  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:
271
265
 
272
266
  ```ruby
273
- devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
267
+ devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
274
268
  ```
275
269
 
276
270
  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`.
277
271
 
278
272
  ### Strong Parameters
279
273
 
280
- ![The Parameter Sanitizer API has changed for Devise 4](http://messages.hellobits.com/warning.svg?message=The%20Parameter%20Sanitizer%20API%20has%20changed%20for%20Devise%204)
274
+ The Parameter Sanitizer API has changed for Devise 4 :warning:
281
275
 
282
- *For previous Devise versions see https://github.com/plataformatec/devise/tree/3-stable#strong-parameters*
276
+ *For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
283
277
 
284
278
  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.
285
279
 
@@ -289,7 +283,7 @@ There are just three actions in Devise that allow any set of parameters to be pa
289
283
  * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
290
284
  * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
291
285
 
292
- In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
286
+ In case you want to permit additional parameters (the lazy way™), you can do so using a simple before action in your `ApplicationController`:
293
287
 
294
288
  ```ruby
295
289
  class ApplicationController < ActionController::Base
@@ -317,7 +311,7 @@ class ApplicationController < ActionController::Base
317
311
  end
318
312
  ```
319
313
 
320
- Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
314
+ Devise allows you to completely change Devise defaults or invoke custom behavior by passing a block:
321
315
 
322
316
  To permit simple scalar values for username and email, use this
323
317
 
@@ -440,7 +434,7 @@ If the customization at the views level is not enough, you can customize each co
440
434
  end
441
435
  ```
442
436
 
443
- Or you can simply add new behaviour to it:
437
+ Or you can simply add new behavior to it:
444
438
 
445
439
  ```ruby
446
440
  class Users::SessionsController < Devise::SessionsController
@@ -464,7 +458,7 @@ Devise also ships with default routes. If you need to customize them, you should
464
458
  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' }
465
459
  ```
466
460
 
467
- Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
461
+ Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
468
462
 
469
463
  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:
470
464
 
@@ -520,7 +514,7 @@ en:
520
514
 
521
515
  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:
522
516
 
523
- https://github.com/plataformatec/devise/wiki/I18n
517
+ https://github.com/heartcombo/devise/wiki/I18n
524
518
 
525
519
  Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
526
520
 
@@ -532,15 +526,21 @@ cases/specs.
532
526
 
533
527
  ### Controller tests
534
528
 
535
- Controller tests require that you include `Devise::Test::ControllerHelpers` on
529
+ Controller tests require that you include `Devise::Test::IntegrationHelpers` on
536
530
  your test case or its parent `ActionController::TestCase` superclass.
537
- For Rails 5, include `Devise::Test::IntegrationHelpers` instead, since the superclass
538
- for controller tests has been changed to ActionDispatch::IntegrationTest
531
+ For Rails versions prior to 5, include `Devise::Test::ControllerHelpers` instead, since the superclass
532
+ for controller tests was changed to ActionDispatch::IntegrationTest
539
533
  (for more details, see the [Integration tests](#integration-tests) section).
540
534
 
541
535
  ```ruby
542
536
  class PostsControllerTest < ActionController::TestCase
543
- include Devise::Test::ControllerHelpers
537
+ include Devise::Test::IntegrationHelpers # Rails >= 5
538
+ end
539
+ ```
540
+
541
+ ```ruby
542
+ class PostsControllerTest < ActionController::TestCase
543
+ include Devise::Test::ControllerHelpers # Rails < 5
544
544
  end
545
545
  ```
546
546
 
@@ -620,7 +620,7 @@ are executed in your tests.
620
620
 
621
621
  You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
622
622
 
623
- * https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
623
+ * https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
624
624
 
625
625
  ### OmniAuth
626
626
 
@@ -632,7 +632,7 @@ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
632
632
 
633
633
  You can read more about OmniAuth support in the wiki:
634
634
 
635
- * https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
635
+ * https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
636
636
 
637
637
  ### Configuring multiple models
638
638
 
@@ -679,12 +679,12 @@ end
679
679
 
680
680
  ### Password reset tokens and Rails logs
681
681
 
682
- If you enable the [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/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:
682
+ If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/master/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:
683
683
 
684
684
  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.
685
685
  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.
686
686
 
687
- Rails sets the production logger level to DEBUG 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`:
687
+ 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`:
688
688
 
689
689
  ```ruby
690
690
  config.log_level = :warn
@@ -697,41 +697,48 @@ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simpl
697
697
 
698
698
  ### Rails API Mode
699
699
 
700
- Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it 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:
700
+ 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/))
701
701
 
702
- ```ruby
703
- Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
704
- Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
705
- ```
702
+ #### Supported Authentication Strategies
703
+ 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))
706
704
 
707
- For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696).
705
+ The devise default for HTTP Auth is disabled, so it will need to be enabled in the devise initializer for the database strategy:
708
706
 
709
- ## Additional information
707
+ ```ruby
708
+ config.http_authenticatable = [:database]
709
+ ```
710
710
 
711
- ### Heroku
711
+ This restriction does not limit you from implementing custom warden strategies, either in your application or via gem-based extensions for devise.
712
+ 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/).
712
713
 
713
- Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
714
+ #### Testing
715
+ 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:
714
716
 
715
717
  ```ruby
716
- config.assets.initialize_on_precompile = false
718
+ Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
719
+ Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
717
720
  ```
718
721
 
719
- Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
722
+ For a deeper understanding of this, review [this issue](https://github.com/heartcombo/devise/issues/4696).
723
+
724
+ Additionally be mindful that without views supported, some email-based flows from Confirmable, Recoverable and Lockable are not supported directly at this time.
725
+
726
+ ## Additional information
720
727
 
721
728
  ### Warden
722
729
 
723
730
  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:
724
731
 
725
- https://github.com/hassox/warden
732
+ https://github.com/wardencommunity/warden
726
733
 
727
734
  ### Contributors
728
735
 
729
736
  We have a long list of valued contributors. Check them all at:
730
737
 
731
- https://github.com/plataformatec/devise/graphs/contributors
738
+ https://github.com/heartcombo/devise/graphs/contributors
732
739
 
733
740
  ## License
734
741
 
735
- MIT License. Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
742
+ MIT License. Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
736
743
 
737
- You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
744
+ The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
@@ -112,7 +112,7 @@ MESSAGE
112
112
  end
113
113
 
114
114
  if authenticated && resource = warden.user(resource_name)
115
- flash[:alert] = I18n.t("devise.failure.already_authenticated")
115
+ set_flash_message(:alert, 'already_authenticated', scope: 'devise.failure')
116
116
  redirect_to after_sign_in_path_for(resource)
117
117
  end
118
118
  end
@@ -184,7 +184,7 @@ MESSAGE
184
184
  options[:default] = Array(options[:default]).unshift(kind.to_sym)
185
185
  options[:resource_name] = resource_name
186
186
  options = devise_i18n_options(options)
187
- I18n.t("#{options[:resource_name]}.#{kind}", options)
187
+ I18n.t("#{options[:resource_name]}.#{kind}", **options)
188
188
  end
189
189
 
190
190
  # Controllers inheriting DeviseController are advised to override this
@@ -1,14 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeviseHelper
4
- # Retain this method for backwards compatibility, deprecated in favour of modifying the
5
- # devise/shared/error_messages partial
4
+ # Retain this method for backwards compatibility, deprecated in favor of modifying the
5
+ # devise/shared/error_messages partial.
6
6
  def devise_error_messages!
7
7
  ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
8
- [Devise] `DeviseHelper.devise_error_messages!`
9
- is deprecated and it will be removed in the next major version.
10
- To customize the errors styles please run `rails g devise:views` and modify the
11
- `devise/shared/error_messages` partial.
8
+ [Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be
9
+ removed in the next major version.
10
+
11
+ Devise now uses a partial under "devise/shared/error_messages" to display
12
+ error messages by default, and make them easier to customize. Update your
13
+ views changing calls from:
14
+
15
+ <%= devise_error_messages! %>
16
+
17
+ to:
18
+
19
+ <%= render "devise/shared/error_messages", resource: resource %>
20
+
21
+ To start customizing how errors are displayed, you can copy the partial
22
+ from devise to your `app/views` folder. Alternatively, you can run
23
+ `rails g devise:views` which will copy all of them again to your app.
12
24
  DEPRECATION
13
25
 
14
26
  return "" if resource.errors.empty?
@@ -4,26 +4,26 @@ if defined?(ActionMailer)
4
4
  class Devise::Mailer < Devise.parent_mailer.constantize
5
5
  include Devise::Mailers::Helpers
6
6
 
7
- def confirmation_instructions(record, token, opts={})
7
+ def confirmation_instructions(record, token, opts = {})
8
8
  @token = token
9
9
  devise_mail(record, :confirmation_instructions, opts)
10
10
  end
11
11
 
12
- def reset_password_instructions(record, token, opts={})
12
+ def reset_password_instructions(record, token, opts = {})
13
13
  @token = token
14
14
  devise_mail(record, :reset_password_instructions, opts)
15
15
  end
16
16
 
17
- def unlock_instructions(record, token, opts={})
17
+ def unlock_instructions(record, token, opts = {})
18
18
  @token = token
19
19
  devise_mail(record, :unlock_instructions, opts)
20
20
  end
21
21
 
22
- def email_changed(record, opts={})
22
+ def email_changed(record, opts = {})
23
23
  devise_mail(record, :email_changed, opts)
24
24
  end
25
25
 
26
- def password_change(record, opts={})
26
+ def password_change(record, opts = {})
27
27
  devise_mail(record, :password_change, opts)
28
28
  end
29
29
  end