devise 4.6.2 → 4.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -4
  3. data/MIT-LICENSE +2 -1
  4. data/README.md +68 -60
  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/passwords/edit.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 +4 -4
  13. data/lib/devise/controllers/url_helpers.rb +1 -1
  14. data/lib/devise/failure_app.rb +5 -12
  15. data/lib/devise/hooks/timeoutable.rb +2 -2
  16. data/lib/devise/mapping.rb +1 -1
  17. data/lib/devise/models/authenticatable.rb +6 -6
  18. data/lib/devise/models/confirmable.rb +14 -2
  19. data/lib/devise/models/database_authenticatable.rb +5 -1
  20. data/lib/devise/models/lockable.rb +1 -1
  21. data/lib/devise/models/recoverable.rb +2 -2
  22. data/lib/devise/models/rememberable.rb +1 -1
  23. data/lib/devise/models/trackable.rb +1 -1
  24. data/lib/devise/models/validatable.rb +1 -1
  25. data/lib/devise/rails/routes.rb +6 -6
  26. data/lib/devise/test/controller_helpers.rb +3 -1
  27. data/lib/devise/test/integration_helpers.rb +1 -1
  28. data/lib/devise/version.rb +1 -1
  29. data/lib/generators/devise/devise_generator.rb +1 -1
  30. data/lib/generators/devise/install_generator.rb +1 -5
  31. data/lib/generators/devise/views_generator.rb +1 -1
  32. data/lib/generators/templates/README +9 -1
  33. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
  34. data/lib/generators/templates/devise.rb +15 -3
  35. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -1
  36. metadata +5 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a3a0aa612778a5a148ace7270243452ffab13eb324584de33ca40243621d5d9
4
- data.tar.gz: c3169895ddf9cb13b168fdff43ef4242104cb04bc7215225a118af451ce2e71d
3
+ metadata.gz: '056338b76007de25ec62deff781ba493d0d063184f70373d31406faf1fc8a219'
4
+ data.tar.gz: 43919f99b2b775b213bf40d5849138339b99462700e58ce5e4a843ab5a63c22f
5
5
  SHA512:
6
- metadata.gz: e386828f44f3082947d1dcd52905ab2d73d6f697d37603023b231a68e7221d1d9a9af3aea4ee2b8344e9cdb3bc6f29137773692e6fc105e1b3c8d1573a7ea7a4
7
- data.tar.gz: 0b087697d505307cfc41723f741e658812b17ac1fc4675e99bef7eab73fcf68143ea9226683a8c3cc0564cb1b61fdf28baa727a5bc2d492491a3e71e4a128ca2
6
+ metadata.gz: b21e1c4b5658dc2077d4eeb4fa70fa25c108bcdbe03b1b1f587d1a8f5c49a2c3b0fa299dc5a45af8b743ba8d8dc968bab768587df12350d41beeb163f6d80af3
7
+ data.tar.gz: c12702819c331ce7739ee30a34cdf550d85db4edbe90ad1c3adffe51c910a27f969938dc098940637c49acc31da0195cc351b56558bf4c2be69961f3071a23c6
@@ -1,9 +1,42 @@
1
- ### Unreleased
1
+ ### 4.7.3 - 2020-09-20
2
+
3
+ * bug fixes
4
+ * Do not modify `:except` option given to `#serializable_hash`. (by @dpep)
5
+ * Fix thor deprecation when running the devise generator. (by @deivid-rodriguez)
6
+ * Fix hanging tests for streaming controllers using Devise. (by @afn)
7
+
8
+ ### 4.7.2 - 2020-06-10
9
+
10
+ * enhancements
11
+ * Increase default stretches to 12 (by @sergey-alekseev)
12
+ * Ruby 2.7 support (kwarg warnings removed)
13
+
14
+ * bug fixes
15
+ * Generate scoped views with proper scoped errors partial (by @shobhitic)
16
+ * Allow to set scoped `already_authenticated` error messages (by @gurgelrenan)
17
+
18
+ ### 4.7.1 - 2019-09-06
19
+
20
+ * bug fixes
21
+ * Fix an edge case where records with a blank `confirmation_token` could be confirmed (by @tegon)
22
+ * Fix typo inside `update_needs_confirmation` i18n key (by @lslm)
23
+
24
+ ### 4.7.0 - 2019-08-19
25
+
26
+ * enhancements
27
+ * Support Rails 6.0
28
+ * Update CI to rails 6.0.0.beta3 (by @tunnes)
29
+ * refactor method name to be more consistent (by @saiqulhaq)
30
+ * Fix rails 6.0.rc1 email uniqueness validation deprecation warning (by @Vasfed)
31
+
32
+ * bug fixes
33
+ * Add `autocomplete="new-password"` to `password_confirmation` fields (by @ferrl)
34
+ * Fix rails_51_and_up? method for Rails 6.rc1 (by @igorkasyanchuk)
2
35
 
3
36
  ### 4.6.2 - 2019-03-26
4
37
 
5
38
  * bug fixes
6
- * 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)
39
+ * 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)
7
40
 
8
41
  ### 4.6.1 - 2019-02-11
9
42
 
@@ -50,7 +83,7 @@
50
83
  * Add `autocomplete="new-password"` to new password fields (by @gssbzn)
51
84
  * Add `autocomplete="current-password"` to current password fields (by @gssbzn)
52
85
  * Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
53
- * Update `simple_form` templates with changes from https://github.com/plataformatec/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/plataformatec/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
86
+ * Update `simple_form` templates with changes from https://github.com/heartcombo/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/heartcombo/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
54
87
  * Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
55
88
 
56
89
  * bug fixes
@@ -297,5 +330,5 @@ configured (by @joshpencheon)
297
330
  You can check more examples and explanations on the [README section](README.md#strong-parameters)
298
331
  and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
299
332
 
300
- Please check [3-stable](https://github.com/plataformatec/devise/blob/3-stable/CHANGELOG.md)
333
+ Please check [3-stable](https://github.com/heartcombo/devise/blob/3-stable/CHANGELOG.md)
301
334
  for previous changes.
@@ -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,7 @@
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
+ [![Build Status](https://api.travis-ci.org/heartcombo/devise.svg?branch=master)](http://travis-ci.org/heartcombo/devise)
4
+ [![Code Climate](https://codeclimate.com/github/heartcombo/devise.svg)](https://codeclimate.com/github/heartcombo/devise)
9
5
 
10
6
  Devise is a flexible authentication solution for Rails based on Warden. It:
11
7
 
@@ -16,16 +12,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
16
12
 
17
13
  It's composed of 10 modules:
18
14
 
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.
15
+ * [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.
16
+ * [Omniauthable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
17
+ * [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.
18
+ * [Recoverable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
19
+ * [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.
20
+ * [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.
21
+ * [Trackable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
22
+ * [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.
23
+ * [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.
24
+ * [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
25
 
30
26
  ## Table of Contents
31
27
 
@@ -58,7 +54,6 @@ It's composed of 10 modules:
58
54
  - [Other ORMs](#other-orms)
59
55
  - [Rails API mode](#rails-api-mode)
60
56
  - [Additional information](#additional-information)
61
- - [Heroku](#heroku)
62
57
  - [Warden](#warden)
63
58
  - [Contributors](#contributors)
64
59
  - [License](#license)
@@ -73,15 +68,15 @@ It's composed of 10 modules:
73
68
 
74
69
  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
70
 
76
- https://github.com/plataformatec/devise/wiki
71
+ https://github.com/heartcombo/devise/wiki
77
72
 
78
73
  ### Bug reports
79
74
 
80
75
  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
76
 
82
- https://github.com/plataformatec/devise/wiki/Bug-reports
77
+ https://github.com/heartcombo/devise/wiki/Bug-reports
83
78
 
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.
79
+ If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
85
80
 
86
81
  ### StackOverflow and Mailing List
87
82
 
@@ -97,7 +92,7 @@ https://groups.google.com/group/plataformatec-devise
97
92
 
98
93
  You can view the Devise documentation in RDoc format here:
99
94
 
100
- http://rubydoc.info/github/plataformatec/devise/master/frames
95
+ http://rubydoc.info/github/heartcombo/devise/master/frames
101
96
 
102
97
  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
98
 
@@ -105,26 +100,26 @@ If you need to use Devise with previous versions of Rails, you can always run "g
105
100
 
106
101
  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
102
 
108
- https://github.com/plataformatec/devise/wiki/Example-Applications
103
+ https://github.com/heartcombo/devise/wiki/Example-Applications
109
104
 
110
105
  ### Extensions
111
106
 
112
107
  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
108
 
114
- https://github.com/plataformatec/devise/wiki/Extensions
109
+ https://github.com/heartcombo/devise/wiki/Extensions
115
110
 
116
111
  ### Contributing
117
112
 
118
113
  We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
119
114
 
120
- https://github.com/plataformatec/devise/wiki/Contributing
115
+ https://github.com/heartcombo/devise/wiki/Contributing
121
116
 
122
117
  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
118
  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
119
 
125
120
  ### DEVISE_ORM
126
121
  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`:
122
+ The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
128
123
  ```
129
124
  DEVISE_ORM=mongoid bin/test
130
125
 
@@ -136,7 +131,7 @@ Please note that the command output will show the variable value being used.
136
131
 
137
132
  ### BUNDLE_GEMFILE
138
133
  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.
134
+ 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 on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
140
135
  For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
141
136
  ```bash
142
137
  rbenv shell 2.4.2 # or rvm use 2.4.2
@@ -170,11 +165,11 @@ bin/test test/models/trackable_test.rb:16
170
165
 
171
166
  ## Starting with Rails?
172
167
 
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:
168
+ 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
169
 
175
170
  * Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
176
- * Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
177
- * Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
171
+ * Ryan Bates' Railscasts: http://railscasts.com/episodes/250-authentication-from-scratch and http://railscasts.com/episodes/250-authentication-from-scratch-revised
172
+ * Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
178
173
 
179
174
  Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
180
175
 
@@ -270,16 +265,16 @@ member_session
270
265
  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
266
 
272
267
  ```ruby
273
- devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
268
+ devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
274
269
  ```
275
270
 
276
271
  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
272
 
278
273
  ### Strong Parameters
279
274
 
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)
275
+ The Parameter Sanitizer API has changed for Devise 4 :warning:
281
276
 
282
- *For previous Devise versions see https://github.com/plataformatec/devise/tree/3-stable#strong-parameters*
277
+ *For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
283
278
 
284
279
  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
280
 
@@ -289,7 +284,7 @@ There are just three actions in Devise that allow any set of parameters to be pa
289
284
  * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
290
285
  * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
291
286
 
292
- In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
287
+ In case you want to permit additional parameters (the lazy way™), you can do so using a simple before action in your `ApplicationController`:
293
288
 
294
289
  ```ruby
295
290
  class ApplicationController < ActionController::Base
@@ -317,7 +312,7 @@ class ApplicationController < ActionController::Base
317
312
  end
318
313
  ```
319
314
 
320
- Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
315
+ Devise allows you to completely change Devise defaults or invoke custom behavior by passing a block:
321
316
 
322
317
  To permit simple scalar values for username and email, use this
323
318
 
@@ -440,7 +435,7 @@ If the customization at the views level is not enough, you can customize each co
440
435
  end
441
436
  ```
442
437
 
443
- Or you can simply add new behaviour to it:
438
+ Or you can simply add new behavior to it:
444
439
 
445
440
  ```ruby
446
441
  class Users::SessionsController < Devise::SessionsController
@@ -464,7 +459,7 @@ Devise also ships with default routes. If you need to customize them, you should
464
459
  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
460
  ```
466
461
 
467
- Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
462
+ Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
468
463
 
469
464
  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
465
 
@@ -520,7 +515,7 @@ en:
520
515
 
521
516
  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
517
 
523
- https://github.com/plataformatec/devise/wiki/I18n
518
+ https://github.com/heartcombo/devise/wiki/I18n
524
519
 
525
520
  Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
526
521
 
@@ -532,15 +527,21 @@ cases/specs.
532
527
 
533
528
  ### Controller tests
534
529
 
535
- Controller tests require that you include `Devise::Test::ControllerHelpers` on
530
+ Controller tests require that you include `Devise::Test::IntegrationHelpers` on
536
531
  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
532
+ For Rails versions prior to 5, include `Devise::Test::ControllerHelpers` instead, since the superclass
533
+ for controller tests was changed to ActionDispatch::IntegrationTest
539
534
  (for more details, see the [Integration tests](#integration-tests) section).
540
535
 
541
536
  ```ruby
542
537
  class PostsControllerTest < ActionController::TestCase
543
- include Devise::Test::ControllerHelpers
538
+ include Devise::Test::IntegrationHelpers # Rails >= 5
539
+ end
540
+ ```
541
+
542
+ ```ruby
543
+ class PostsControllerTest < ActionController::TestCase
544
+ include Devise::Test::ControllerHelpers # Rails < 5
544
545
  end
545
546
  ```
546
547
 
@@ -620,7 +621,7 @@ are executed in your tests.
620
621
 
621
622
  You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
622
623
 
623
- * https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
624
+ * https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
624
625
 
625
626
  ### OmniAuth
626
627
 
@@ -632,7 +633,7 @@ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
632
633
 
633
634
  You can read more about OmniAuth support in the wiki:
634
635
 
635
- * https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
636
+ * https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
636
637
 
637
638
  ### Configuring multiple models
638
639
 
@@ -679,7 +680,7 @@ end
679
680
 
680
681
  ### Password reset tokens and Rails logs
681
682
 
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:
683
+ 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
684
 
684
685
  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
686
  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.
@@ -697,41 +698,48 @@ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simpl
697
698
 
698
699
  ### Rails API Mode
699
700
 
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:
701
+ 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
702
 
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
- ```
703
+ #### Supported Authentication Strategies
704
+ 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
705
 
707
- For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696).
706
+ The devise default for HTTP Auth is disabled, so it will need to be enabled in the devise initializer for the database strategy:
708
707
 
709
- ## Additional information
708
+ ```ruby
709
+ config.http_authenticatable = [:database]
710
+ ```
710
711
 
711
- ### Heroku
712
+ This restriction does not limit you from implementing custom warden strategies, either in your application or via gem-based extensions for devise.
713
+ 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
714
 
713
- Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
715
+ #### Testing
716
+ 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
717
 
715
718
  ```ruby
716
- config.assets.initialize_on_precompile = false
719
+ Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
720
+ Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
717
721
  ```
718
722
 
719
- Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
723
+ For a deeper understanding of this, review [this issue](https://github.com/heartcombo/devise/issues/4696).
724
+
725
+ Additionally be mindful that without views supported, some email-based flows from Confirmable, Recoverable and Lockable are not supported directly at this time.
726
+
727
+ ## Additional information
720
728
 
721
729
  ### Warden
722
730
 
723
731
  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
732
 
725
- https://github.com/hassox/warden
733
+ https://github.com/wardencommunity/warden
726
734
 
727
735
  ### Contributors
728
736
 
729
737
  We have a long list of valued contributors. Check them all at:
730
738
 
731
- https://github.com/plataformatec/devise/graphs/contributors
739
+ https://github.com/heartcombo/devise/graphs/contributors
732
740
 
733
741
  ## License
734
742
 
735
- MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
743
+ MIT License. Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
736
744
 
737
- You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
745
+ 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
@@ -14,7 +14,7 @@
14
14
 
15
15
  <div class="field">
16
16
  <%= f.label :password_confirmation, "Confirm new password" %><br />
17
- <%= f.password_field :password_confirmation, autocomplete: "off" %>
17
+ <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
18
18
  </div>
19
19
 
20
20
  <div class="actions">
@@ -1,4 +1,4 @@
1
- # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
1
+ # Additional translations at https://github.com/heartcombo/devise/wiki/I18n
2
2
 
3
3
  en:
4
4
  devise:
@@ -42,7 +42,7 @@ en:
42
42
  signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43
43
  signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44
44
  signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45
- update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
45
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
46
46
  updated: "Your account has been updated successfully."
47
47
  updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
48
48
  sessions:
@@ -71,7 +71,7 @@ module Devise
71
71
 
72
72
  # The number of times to hash the password.
73
73
  mattr_accessor :stretches
74
- @@stretches = 11
74
+ @@stretches = 12
75
75
 
76
76
  # The default key used when authenticating over http auth.
77
77
  mattr_accessor :http_authentication_key
@@ -297,10 +297,6 @@ module Devise
297
297
  mattr_accessor :sign_in_after_change_password
298
298
  @@sign_in_after_change_password = true
299
299
 
300
- def self.rails51? # :nodoc:
301
- Rails.gem_version >= Gem::Version.new("5.1.x")
302
- end
303
-
304
300
  def self.activerecord51? # :nodoc:
305
301
  defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
306
302
  end
@@ -36,14 +36,14 @@ module Devise
36
36
  # before_action ->{ authenticate_blogger! :admin } # Redirects to the admin login page
37
37
  # current_blogger :user # Preferably returns a User if one is signed in
38
38
  #
39
- def devise_group(group_name, opts={})
39
+ def devise_group(group_name, opts = {})
40
40
  mappings = "[#{ opts[:contains].map { |m| ":#{m}" }.join(',') }]"
41
41
 
42
42
  class_eval <<-METHODS, __FILE__, __LINE__ + 1
43
- def authenticate_#{group_name}!(favourite=nil, opts={})
43
+ def authenticate_#{group_name}!(favorite = nil, opts = {})
44
44
  unless #{group_name}_signed_in?
45
45
  mappings = #{mappings}
46
- mappings.unshift mappings.delete(favourite.to_sym) if favourite
46
+ mappings.unshift mappings.delete(favorite.to_sym) if favorite
47
47
  mappings.each do |mapping|
48
48
  opts[:scope] = mapping
49
49
  warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
@@ -57,9 +57,9 @@ module Devise
57
57
  end
58
58
  end
59
59
 
60
- def current_#{group_name}(favourite=nil)
60
+ def current_#{group_name}(favorite = nil)
61
61
  mappings = #{mappings}
62
- mappings.unshift mappings.delete(favourite.to_sym) if favourite
62
+ mappings.unshift mappings.delete(favorite.to_sym) if favorite
63
63
  mappings.each do |mapping|
64
64
  current = warden.authenticate(scope: mapping)
65
65
  return current if current
@@ -113,7 +113,7 @@ module Devise
113
113
  mapping = mapping.name
114
114
 
115
115
  class_eval <<-METHODS, __FILE__, __LINE__ + 1
116
- def authenticate_#{mapping}!(opts={})
116
+ def authenticate_#{mapping}!(opts = {})
117
117
  opts[:scope] = :#{mapping}
118
118
  warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
119
119
  end
@@ -252,7 +252,7 @@ module Devise
252
252
  # Overwrite Rails' handle unverified request to sign out all scopes,
253
253
  # clear run strategies and remove cached variables.
254
254
  def handle_unverified_request
255
- super # call the default behaviour which resets/nullifies/raises
255
+ super # call the default behavior which resets/nullifies/raises
256
256
  request.env["devise.skip_storage"] = true
257
257
  sign_out_all_scopes(false)
258
258
  end
@@ -10,7 +10,7 @@ module Devise
10
10
  # cause exceptions to be thrown from this method; if you simply want to check
11
11
  # if a scope has already previously been authenticated without running
12
12
  # authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
13
- def signed_in?(scope=nil)
13
+ def signed_in?(scope = nil)
14
14
  [scope || Devise.mappings.keys].flatten.any? do |_scope|
15
15
  warden.authenticate?(scope: _scope)
16
16
  end
@@ -21,7 +21,7 @@ module Devise
21
21
  # to the set_user method in warden.
22
22
  # If you are using a custom warden strategy and the timeoutable module, you have to
23
23
  # set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
24
- # in the sessions controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
24
+ # in the sessions controller: https://github.com/heartcombo/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
25
25
  #
26
26
  # Examples:
27
27
  #
@@ -77,7 +77,7 @@ module Devise
77
77
  # sign_out :user # sign_out(scope)
78
78
  # sign_out @user # sign_out(resource)
79
79
  #
80
- def sign_out(resource_or_scope=nil)
80
+ def sign_out(resource_or_scope = nil)
81
81
  return sign_out_all_scopes unless resource_or_scope
82
82
  scope = Devise::Mapping.find_scope!(resource_or_scope)
83
83
  user = warden.user(scope: scope, run_callbacks: false) # If there is no user
@@ -92,7 +92,7 @@ module Devise
92
92
  # Sign out all active users or scopes. This helper is useful for signing out all roles
93
93
  # in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
94
94
  # and false if there was no user logged in on all scopes.
95
- def sign_out_all_scopes(lock=true)
95
+ def sign_out_all_scopes(lock = true)
96
96
  users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
97
97
 
98
98
  warden.logout
@@ -34,7 +34,7 @@ module Devise
34
34
  end
35
35
  end
36
36
 
37
- def self.generate_helpers!(routes=nil)
37
+ def self.generate_helpers!(routes = nil)
38
38
  routes ||= begin
39
39
  mappings = Devise.mappings.values.map(&:used_helpers).flatten.uniq
40
40
  Devise::URL_HELPERS.slice(*mappings)
@@ -71,7 +71,6 @@ module Devise
71
71
  end
72
72
 
73
73
  flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
74
- # self.response = recall_app(warden_options[:recall]).call(env)
75
74
  self.response = recall_app(warden_options[:recall]).call(request.env)
76
75
  end
77
76
 
@@ -107,7 +106,7 @@ module Devise
107
106
  options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
108
107
  options = i18n_options(options)
109
108
 
110
- I18n.t(:"#{scope}.#{message}", options)
109
+ I18n.t(:"#{scope}.#{message}", **options)
111
110
  else
112
111
  message.to_s
113
112
  end
@@ -152,8 +151,8 @@ module Devise
152
151
 
153
152
  # We need to add the rootpath to `script_name` manually for applications that use a Rails
154
153
  # version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
155
- # that use Devise. Remove it when the support of Rails 5.0 is droped.
156
- elsif root_path_defined?(context) && rails_5_and_down?
154
+ # that use Devise. Remove it when the support of Rails 5.0 is dropped.
155
+ elsif root_path_defined?(context) && !rails_51_and_up?
157
156
  rootpath = context.routes.url_helpers.root_path
158
157
  opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
159
158
  end
@@ -278,14 +277,8 @@ module Devise
278
277
  defined?(context.routes) && context.routes.url_helpers.respond_to?(:root_path)
279
278
  end
280
279
 
281
- def rails_5_and_down?
282
- return false if rails_5_up?
283
-
284
- Rails::VERSION::MAJOR >= 4
285
- end
286
-
287
- def rails_5_up?
288
- Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR > 0
280
+ def rails_51_and_up?
281
+ Rails.gem_version >= Gem::Version.new("5.1")
289
282
  end
290
283
  end
291
284
  end
@@ -21,8 +21,8 @@ Warden::Manager.after_set_user do |record, warden, options|
21
21
 
22
22
  proxy = Devise::Hooks::Proxy.new(warden)
23
23
 
24
- if record.timedout?(last_request_at) &&
25
- !env['devise.skip_timeout'] &&
24
+ if !env['devise.skip_timeout'] &&
25
+ record.timedout?(last_request_at) &&
26
26
  !proxy.remember_me_is_active?(record)
27
27
  Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope)
28
28
  throw :warden, scope: scope, message: :timeout
@@ -46,7 +46,7 @@ module Devise
46
46
  raise "Could not find a valid mapping for #{obj.inspect}"
47
47
  end
48
48
 
49
- def self.find_by_path!(path, path_type=:fullpath)
49
+ def self.find_by_path!(path, path_type = :fullpath)
50
50
  Devise.mappings.each_value { |m| return m if path.include?(m.send(path_type)) }
51
51
  raise "Could not find a valid mapping for path #{path.inspect}"
52
52
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_model/version'
4
3
  require 'devise/hooks/activatable'
5
4
  require 'devise/hooks/csrf_cleaner'
6
5
 
@@ -105,7 +104,7 @@ module Devise
105
104
  # given to :except will simply add names to exempt to Devise internal list.
106
105
  def serializable_hash(options = nil)
107
106
  options = options.try(:dup) || {}
108
- options[:except] = Array(options[:except])
107
+ options[:except] = Array(options[:except]).dup
109
108
 
110
109
  if options[:force_except]
111
110
  options[:except].concat Array(options[:force_except])
@@ -153,7 +152,8 @@ module Devise
153
152
  # # If the record is new or changed then delay the
154
153
  # # delivery until the after_commit callback otherwise
155
154
  # # send now because after_commit will not be called.
156
- # if new_record? || changed?
155
+ # # For Rails < 6 use `changed?` instead of `saved_changes?`.
156
+ # if new_record? || saved_changes?
157
157
  # pending_devise_notifications << [notification, args]
158
158
  # else
159
159
  # render_and_send_devise_message(notification, *args)
@@ -272,17 +272,17 @@ module Devise
272
272
  find_first_by_auth_conditions(tainted_conditions)
273
273
  end
274
274
 
275
- def find_first_by_auth_conditions(tainted_conditions, opts={})
275
+ def find_first_by_auth_conditions(tainted_conditions, opts = {})
276
276
  to_adapter.find_first(devise_parameter_filter.filter(tainted_conditions).merge(opts))
277
277
  end
278
278
 
279
279
  # Find or initialize a record setting an error if it can't be found.
280
- def find_or_initialize_with_error_by(attribute, value, error=:invalid) #:nodoc:
280
+ def find_or_initialize_with_error_by(attribute, value, error = :invalid) #:nodoc:
281
281
  find_or_initialize_with_errors([attribute], { attribute => value }, error)
282
282
  end
283
283
 
284
284
  # Find or initialize a record with group of attributes based on a list of required attributes.
285
- def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
285
+ def find_or_initialize_with_errors(required_attributes, attributes, error = :invalid) #:nodoc:
286
286
  attributes.try(:permit!)
287
287
  attributes = attributes.to_h.with_indifferent_access
288
288
  .slice(*required_attributes)
@@ -76,7 +76,7 @@ module Devise
76
76
  # Confirm a user by setting it's confirmed_at to actual time. If the user
77
77
  # is already confirmed, add an error to email field. If the user is invalid
78
78
  # add errors
79
- def confirm(args={})
79
+ def confirm(args = {})
80
80
  pending_any_confirmation do
81
81
  if confirmation_period_expired?
82
82
  self.errors.add(:email, :confirmation_period_expired,
@@ -334,7 +334,7 @@ module Devise
334
334
  # confirmation instructions to it. If not, try searching for a user by unconfirmed_email
335
335
  # field. If no user is found, returns a new user with an email not found error.
336
336
  # Options must contain the user email
337
- def send_confirmation_instructions(attributes={})
337
+ def send_confirmation_instructions(attributes = {})
338
338
  confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
339
339
  unless confirmable.try(:persisted?)
340
340
  confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
@@ -348,7 +348,19 @@ module Devise
348
348
  # If the user is already confirmed, create an error for the user
349
349
  # Options must have the confirmation_token
350
350
  def confirm_by_token(confirmation_token)
351
+ # When the `confirmation_token` parameter is blank, if there are any users with a blank
352
+ # `confirmation_token` in the database, the first one would be confirmed here.
353
+ # The error is being manually added here to ensure no users are confirmed by mistake.
354
+ # This was done in the model for convenience, since validation errors are automatically
355
+ # displayed in the view.
356
+ if confirmation_token.blank?
357
+ confirmable = new
358
+ confirmable.errors.add(:confirmation_token, :blank)
359
+ return confirmable
360
+ end
361
+
351
362
  confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token)
363
+
352
364
  unless confirmable
353
365
  confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
354
366
  confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest)
@@ -7,6 +7,10 @@ module Devise
7
7
  # Authenticatable Module, responsible for hashing the password and
8
8
  # validating the authenticity of a user while signing in.
9
9
  #
10
+ # This module defines a `password=` method. This method will hash the argument
11
+ # and store it in the `encrypted_password` column, bypassing any pre-existing
12
+ # `password` column if it exists.
13
+ #
10
14
  # == Options
11
15
  #
12
16
  # DatabaseAuthenticatable adds the following options to devise_for:
@@ -195,7 +199,7 @@ module Devise
195
199
  # Hashes the password using bcrypt. Custom hash functions should override
196
200
  # this method to apply their own algorithm.
197
201
  #
198
- # See https://github.com/plataformatec/devise-encryptable for examples
202
+ # See https://github.com/heartcombo/devise-encryptable for examples
199
203
  # of other hashing engines.
200
204
  def password_digest(password)
201
205
  Devise::Encryptor.digest(self.class, password)
@@ -168,7 +168,7 @@ module Devise
168
168
  # unlock instructions to it. If not user is found, returns a new user
169
169
  # with an email not found error.
170
170
  # Options must contain the user's unlock keys
171
- def send_unlock_instructions(attributes={})
171
+ def send_unlock_instructions(attributes = {})
172
172
  lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
173
173
  lockable.resend_unlock_instructions if lockable.persisted?
174
174
  lockable
@@ -131,7 +131,7 @@ module Devise
131
131
  # password instructions to it. If user is not found, returns a new user
132
132
  # with an email not found error.
133
133
  # Attributes must contain the user's email
134
- def send_reset_password_instructions(attributes={})
134
+ def send_reset_password_instructions(attributes = {})
135
135
  recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
136
136
  recoverable.send_reset_password_instructions if recoverable.persisted?
137
137
  recoverable
@@ -142,7 +142,7 @@ module Devise
142
142
  # try saving the record. If not user is found, returns a new user
143
143
  # containing an error in reset_password_token attribute.
144
144
  # Attributes must contain reset_password_token, password and confirmation
145
- def reset_password_by_token(attributes={})
145
+ def reset_password_by_token(attributes = {})
146
146
  original_token = attributes[:reset_password_token]
147
147
  reset_password_token = Devise.token_generator.digest(self, :reset_password_token, original_token)
148
148
 
@@ -102,7 +102,7 @@ module Devise
102
102
 
103
103
  def remember_me?(token, generated_at)
104
104
  # TODO: Normalize the JSON type coercion along with the Timeoutable hook
105
- # in a single place https://github.com/plataformatec/devise/blob/ffe9d6d406e79108cf32a2c6a1d0b3828849c40b/lib/devise/hooks/timeoutable.rb#L14-L18
105
+ # in a single place https://github.com/heartcombo/devise/blob/ffe9d6d406e79108cf32a2c6a1d0b3828849c40b/lib/devise/hooks/timeoutable.rb#L14-L18
106
106
  if generated_at.is_a?(String)
107
107
  generated_at = time_from_json(generated_at)
108
108
  end
@@ -33,7 +33,7 @@ module Devise
33
33
  def update_tracked_fields!(request)
34
34
  # We have to check if the user is already persisted before running
35
35
  # `save` here because invalid users can be saved if we don't.
36
- # See https://github.com/plataformatec/devise/issues/4673 for more details.
36
+ # See https://github.com/heartcombo/devise/issues/4673 for more details.
37
37
  return if new_record?
38
38
 
39
39
  update_tracked_fields(request)
@@ -30,7 +30,7 @@ module Devise
30
30
  base.class_eval do
31
31
  validates_presence_of :email, if: :email_required?
32
32
  if Devise.activerecord51?
33
- validates_uniqueness_of :email, allow_blank: true, if: :will_save_change_to_email?
33
+ validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :will_save_change_to_email?
34
34
  validates_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
35
35
  else
36
36
  validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
@@ -135,10 +135,10 @@ module ActionDispatch::Routing
135
135
  # * failure_app: a rack app which is invoked whenever there is a failure. Strings representing a given
136
136
  # are also allowed as parameter.
137
137
  #
138
- # * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :get),
138
+ # * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :delete),
139
139
  # if you wish to restrict this to accept only :post or :delete requests you should do:
140
140
  #
141
- # devise_for :users, sign_out_via: [:post, :delete]
141
+ # devise_for :users, sign_out_via: [:get, :post]
142
142
  #
143
143
  # You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
144
144
  #
@@ -287,7 +287,7 @@ module ActionDispatch::Routing
287
287
  # root to: "admin/dashboard#show", as: :user_root
288
288
  # end
289
289
  #
290
- def authenticate(scope=nil, block=nil)
290
+ def authenticate(scope = nil, block = nil)
291
291
  constraints_for(:authenticate!, scope, block) do
292
292
  yield
293
293
  end
@@ -311,7 +311,7 @@ module ActionDispatch::Routing
311
311
  #
312
312
  # root to: 'landing#show'
313
313
  #
314
- def authenticated(scope=nil, block=nil)
314
+ def authenticated(scope = nil, block = nil)
315
315
  constraints_for(:authenticate?, scope, block) do
316
316
  yield
317
317
  end
@@ -328,7 +328,7 @@ module ActionDispatch::Routing
328
328
  #
329
329
  # root to: 'dashboard#show'
330
330
  #
331
- def unauthenticated(scope=nil)
331
+ def unauthenticated(scope = nil)
332
332
  constraint = lambda do |request|
333
333
  not request.env["warden"].authenticate? scope: scope
334
334
  end
@@ -474,7 +474,7 @@ ERROR
474
474
  @scope = current_scope
475
475
  end
476
476
 
477
- def constraints_for(method_to_apply, scope=nil, block=nil)
477
+ def constraints_for(method_to_apply, scope = nil, block = nil)
478
478
  constraint = lambda do |request|
479
479
  request.env['warden'].send(method_to_apply, scope: scope) &&
480
480
  (block.nil? || block.call(request.env["warden"].user(scope)))
@@ -37,6 +37,8 @@ module Devise
37
37
  @response
38
38
  end
39
39
 
40
+ ruby2_keywords(:process) if respond_to?(:ruby2_keywords, true)
41
+
40
42
  # We need to set up the environment variables and the response in the controller.
41
43
  def setup_controller_for_warden #:nodoc:
42
44
  @request.env['action_controller.instance'] = @controller
@@ -141,7 +143,7 @@ module Devise
141
143
  @controller.response.headers.merge!(headers)
142
144
  @controller.response.content_type = headers["Content-Type"] unless Rails::VERSION::MAJOR >= 5
143
145
  @controller.status = status
144
- @controller.response.body = response.body
146
+ @controller.response_body = response.body
145
147
  nil # causes process return @response
146
148
  end
147
149
 
@@ -28,7 +28,7 @@ module Devise
28
28
  end
29
29
  end
30
30
 
31
- # Signs in a specific resource, mimicking a successfull sign in
31
+ # Signs in a specific resource, mimicking a successful sign in
32
32
  # operation through +Devise::SessionsController#create+.
33
33
  #
34
34
  # * +resource+ - The resource that should be authenticated
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devise
4
- VERSION = "4.6.2".freeze
4
+ VERSION = "4.7.3".freeze
5
5
  end
@@ -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]
@@ -37,10 +37,6 @@ module Devise
37
37
  def show_readme
38
38
  readme "README" if behavior == :invoke
39
39
  end
40
-
41
- def rails_4?
42
- Rails::VERSION::MAJOR == 4
43
- end
44
40
  end
45
41
  end
46
42
  end
@@ -42,7 +42,7 @@ module Devise
42
42
  def view_directory(name, _target_path = nil)
43
43
  directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
44
44
  if scope
45
- content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
45
+ content.gsub("devise/shared", "#{plural_scope}/shared")
46
46
  else
47
47
  content
48
48
  end
@@ -1,6 +1,6 @@
1
1
  ===============================================================================
2
2
 
3
- Some setup you must do manually if you haven't yet:
3
+ Depending on your application's configuration some manual setup may be required:
4
4
 
5
5
  1. Ensure you have defined default url options in your environments files. Here
6
6
  is an example of default_url_options appropriate for a development environment
@@ -10,10 +10,14 @@ Some setup you must do manually if you haven't yet:
10
10
 
11
11
  In production, :host should be set to the actual host of your application.
12
12
 
13
+ * Required for all applications. *
14
+
13
15
  2. Ensure you have defined root_url to *something* in your config/routes.rb.
14
16
  For example:
15
17
 
16
18
  root to: "home#index"
19
+
20
+ * Not required for API-only Applications *
17
21
 
18
22
  3. Ensure you have flash messages in app/views/layouts/application.html.erb.
19
23
  For example:
@@ -21,8 +25,12 @@ Some setup you must do manually if you haven't yet:
21
25
  <p class="notice"><%= notice %></p>
22
26
  <p class="alert"><%= alert %></p>
23
27
 
28
+ * Not required for API-only Applications *
29
+
24
30
  4. You can copy Devise views (for customization) to your app by running:
25
31
 
26
32
  rails g devise:views
33
+
34
+ * Not required *
27
35
 
28
36
  ===============================================================================
@@ -9,7 +9,7 @@ class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallback
9
9
  # end
10
10
 
11
11
  # More info at:
12
- # https://github.com/plataformatec/devise#omniauth
12
+ # https://github.com/heartcombo/devise#omniauth
13
13
 
14
14
  # GET|POST /resource/auth/twitter
15
15
  # def passthru
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Assuming you have not yet modified this file, each configuration option below
4
+ # is set to its default value. Note that some are commented out while others
5
+ # are not: uncommented lines are intended to protect your configuration from
6
+ # breaking changes in upgrades (i.e., in the event that future versions of
7
+ # Devise change the default values for those options).
8
+ #
3
9
  # Use this hook to configure devise mailer, warden hooks and so forth.
4
10
  # Many of these configuration options can be set straight in your model.
5
11
  Devise.setup do |config|
@@ -68,7 +74,10 @@ Devise.setup do |config|
68
74
  # Tell if authentication through HTTP Auth is enabled. False by default.
69
75
  # It can be set to an array that will enable http authentication only for the
70
76
  # given strategies, for example, `config.http_authenticatable = [:database]` will
71
- # enable it only for database authentication. The supported strategies are:
77
+ # enable it only for database authentication.
78
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
79
+ # enable this with :database unless you are using a custom strategy.
80
+ # The supported strategies are:
72
81
  # :database = Support basic authentication with authentication key + password
73
82
  # config.http_authenticatable = false
74
83
 
@@ -103,15 +112,18 @@ Devise.setup do |config|
103
112
  # config.reload_routes = true
104
113
 
105
114
  # ==> Configuration for :database_authenticatable
106
- # For bcrypt, this is the cost for hashing the password and defaults to 11. If
115
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
107
116
  # using other algorithms, it sets how many times you want the password to be hashed.
117
+ # The number of stretches used for generating the hashed password are stored
118
+ # with the hashed password. This allows you to change the stretches without
119
+ # invalidating existing passwords.
108
120
  #
109
121
  # Limiting the stretches to just one in testing will increase the performance of
110
122
  # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
111
123
  # a value less than 10 in other environments. Note that, for bcrypt (the default
112
124
  # algorithm), the cost increases exponentially with the number of stretches (e.g.
113
125
  # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
114
- config.stretches = Rails.env.test? ? 1 : 11
126
+ config.stretches = Rails.env.test? ? 1 : 12
115
127
 
116
128
  # Set up a pepper to generate the hashed password.
117
129
  # config.pepper = '<%= SecureRandom.hex(64) %>'
@@ -13,7 +13,10 @@
13
13
  autofocus: true,
14
14
  hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
15
15
  input_html: { autocomplete: "new-password" } %>
16
- <%= f.input :password_confirmation, label: "Confirm your new password", required: true %>
16
+ <%= f.input :password_confirmation,
17
+ label: "Confirm your new password",
18
+ required: true,
19
+ input_html: { autocomplete: "new-password" } %>
17
20
  </div>
18
21
 
19
22
  <div class="form-actions">
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.6.2
4
+ version: 4.7.3
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: 2019-03-26 00:00:00.000000000 Z
12
+ date: 2020-09-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: warden
@@ -60,9 +60,6 @@ dependencies:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 4.1.0
63
- - - "<"
64
- - !ruby/object:Gem::Version
65
- version: '6.0'
66
63
  type: :runtime
67
64
  prerelease: false
68
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -70,9 +67,6 @@ dependencies:
70
67
  - - ">="
71
68
  - !ruby/object:Gem::Version
72
69
  version: 4.1.0
73
- - - "<"
74
- - !ruby/object:Gem::Version
75
- version: '6.0'
76
70
  - !ruby/object:Gem::Dependency
77
71
  name: responders
78
72
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +82,7 @@ dependencies:
88
82
  - !ruby/object:Gem::Version
89
83
  version: '0'
90
84
  description: Flexible authentication solution for Rails with Warden
91
- email: contact@plataformatec.com.br
85
+ email: heartcombo@googlegroups.com
92
86
  executables: []
93
87
  extensions: []
94
88
  extra_rdoc_files: []
@@ -204,7 +198,7 @@ files:
204
198
  - lib/generators/templates/simple_form_for/registrations/new.html.erb
205
199
  - lib/generators/templates/simple_form_for/sessions/new.html.erb
206
200
  - lib/generators/templates/simple_form_for/unlocks/new.html.erb
207
- homepage: https://github.com/plataformatec/devise
201
+ homepage: https://github.com/heartcombo/devise
208
202
  licenses:
209
203
  - MIT
210
204
  metadata: {}
@@ -223,8 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
217
  - !ruby/object:Gem::Version
224
218
  version: '0'
225
219
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.7.6
220
+ rubygems_version: 3.0.3
228
221
  signing_key:
229
222
  specification_version: 4
230
223
  summary: Flexible authentication solution for Rails with Warden