devise 4.9.4 → 5.0.0.rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -392
  3. data/MIT-LICENSE +2 -2
  4. data/README.md +51 -47
  5. data/app/controllers/devise/confirmations_controller.rb +1 -1
  6. data/app/controllers/devise/sessions_controller.rb +4 -4
  7. data/app/controllers/devise/unlocks_controller.rb +1 -1
  8. data/app/helpers/devise_helper.rb +1 -26
  9. data/app/views/devise/confirmations/new.html.erb +2 -2
  10. data/app/views/devise/passwords/edit.html.erb +5 -5
  11. data/app/views/devise/passwords/new.html.erb +3 -3
  12. data/app/views/devise/registrations/edit.html.erb +9 -10
  13. data/app/views/devise/registrations/new.html.erb +8 -8
  14. data/app/views/devise/sessions/new.html.erb +6 -6
  15. data/app/views/devise/shared/_error_messages.html.erb +1 -1
  16. data/app/views/devise/shared/_links.html.erb +6 -6
  17. data/app/views/devise/unlocks/new.html.erb +2 -2
  18. data/lib/devise/controllers/sign_in_out.rb +1 -16
  19. data/lib/devise/failure_app.rb +12 -24
  20. data/lib/devise/hooks/activatable.rb +1 -1
  21. data/lib/devise/hooks/timeoutable.rb +1 -1
  22. data/lib/devise/mailers/helpers.rb +9 -15
  23. data/lib/devise/mapping.rb +1 -1
  24. data/lib/devise/models/authenticatable.rb +2 -14
  25. data/lib/devise/models/database_authenticatable.rb +6 -24
  26. data/lib/devise/models/lockable.rb +1 -1
  27. data/lib/devise/models/validatable.rb +3 -1
  28. data/lib/devise/orm.rb +10 -12
  29. data/lib/devise/parameter_sanitizer.rb +1 -2
  30. data/lib/devise/rails/routes.rb +3 -4
  31. data/lib/devise/rails.rb +7 -1
  32. data/lib/devise/test/controller_helpers.rb +1 -12
  33. data/lib/devise/version.rb +1 -1
  34. data/lib/devise.rb +12 -20
  35. data/lib/generators/active_record/devise_generator.rb +5 -11
  36. data/lib/generators/devise/controllers_generator.rb +1 -1
  37. data/lib/generators/templates/devise.rb +7 -4
  38. metadata +7 -16
  39. data/lib/devise/rails/deprecated_constant_accessor.rb +0 -39
  40. data/lib/devise/secret_key_finder.rb +0 -27
  41. data/lib/devise/test_helpers.rb +0 -15
data/README.md CHANGED
@@ -9,16 +9,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
9
9
 
10
10
  It's composed of 10 modules:
11
11
 
12
- * [Database Authenticatable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
13
- * [Omniauthable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
14
- * [Confirmable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
15
- * [Recoverable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Recoverable): resets the user password and sends reset instructions.
16
- * [Registerable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
17
- * [Rememberable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
18
- * [Trackable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
19
- * [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
20
- * [Validatable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
21
- * [Lockable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
12
+ * [Database Authenticatable](https://www.rubydoc.info/gems/devise/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
13
+ * [Omniauthable](https://www.rubydoc.info/gems/devise/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
14
+ * [Confirmable](https://www.rubydoc.info/gems/devise/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
15
+ * [Recoverable](https://www.rubydoc.info/gems/devise/Devise/Models/Recoverable): resets the user password and sends reset instructions.
16
+ * [Registerable](https://www.rubydoc.info/gems/devise/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
17
+ * [Rememberable](https://www.rubydoc.info/gems/devise/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
18
+ * [Trackable](https://www.rubydoc.info/gems/devise/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
19
+ * [Timeoutable](https://www.rubydoc.info/gems/devise/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
20
+ * [Validatable](https://www.rubydoc.info/gems/devise/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
21
+ * [Lockable](https://www.rubydoc.info/gems/devise/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.
22
22
 
23
23
  ## Table of Contents
24
24
 
@@ -31,6 +31,7 @@ It's composed of 10 modules:
31
31
  - [RDocs](#rdocs)
32
32
  - [Example applications](#example-applications)
33
33
  - [Extensions](#extensions)
34
+ - [Supported Ruby / Rails versions](#supported-ruby--rails-versions)
34
35
  - [Contributing](#contributing)
35
36
  - [Starting with Rails?](#starting-with-rails)
36
37
  - [Getting started](#getting-started)
@@ -52,7 +53,6 @@ It's composed of 10 modules:
52
53
  - [Rails API mode](#rails-api-mode)
53
54
  - [Additional information](#additional-information)
54
55
  - [Warden](#warden)
55
- - [Contributors](#contributors)
56
56
  - [License](#license)
57
57
 
58
58
  <!-- /TOC -->
@@ -73,7 +73,7 @@ If you discover a problem with Devise, we would like to know about it. However,
73
73
 
74
74
  https://github.com/heartcombo/devise/wiki/Bug-reports
75
75
 
76
- If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
76
+ If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo.oss@gmail.com.
77
77
 
78
78
  ### StackOverflow and Mailing List
79
79
 
@@ -81,9 +81,10 @@ If you have any questions, comments, or concerns, please use StackOverflow inste
81
81
 
82
82
  http://stackoverflow.com/questions/tagged/devise
83
83
 
84
- The deprecated mailing list can still be read on
84
+ The deprecated mailing lists can still be read on:
85
85
 
86
86
  https://groups.google.com/group/plataformatec-devise
87
+ https://groups.google.com/group/heartcombo
87
88
 
88
89
  ### RDocs
89
90
 
@@ -105,6 +106,13 @@ Our community has created a number of extensions that add functionality above an
105
106
 
106
107
  https://github.com/heartcombo/devise/wiki/Extensions
107
108
 
109
+ ### Supported Ruby / Rails versions
110
+
111
+ We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
112
+
113
+ For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
114
+ and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
115
+
108
116
  ### Contributing
109
117
 
110
118
  We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
@@ -114,7 +122,7 @@ https://github.com/heartcombo/devise/wiki/Contributing
114
122
  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`.
115
123
  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`.
116
124
 
117
- ### DEVISE_ORM
125
+ #### DEVISE_ORM
118
126
  Since Devise supports both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
119
127
  The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
120
128
  ```
@@ -126,20 +134,20 @@ When running the tests for Mongoid, you will need to have a MongoDB server (vers
126
134
 
127
135
  Please note that the command output will show the variable value being used.
128
136
 
129
- ### BUNDLE_GEMFILE
137
+ #### BUNDLE_GEMFILE
130
138
  We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
131
139
  Inside the [gemfiles](https://github.com/heartcombo/devise/tree/main/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
132
- For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
140
+ For example, if the tests broke using Ruby 3.4 and Rails 8.0, you can do the following:
133
141
  ```bash
134
- rbenv shell 2.4.2 # or rvm use 2.4.2
135
- BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
136
- BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
142
+ chruby 3.4.0 # or rbenv shell 3.4.0, or rvm use 3.4.0, etc.
143
+ BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 bundle install
144
+ BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 bin/test
137
145
  ```
138
146
 
139
147
  You can also combine both of them if the tests broke for Mongoid:
140
148
  ```bash
141
- BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
142
- BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
149
+ BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 bundle install
150
+ BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 DEVISE_ORM=mongoid bin/test
143
151
  ```
144
152
 
145
153
  ### Running tests
@@ -155,9 +163,10 @@ bin/test
155
163
  bin/test test/models/trackable_test.rb
156
164
  ```
157
165
 
158
- * Running a specific test given a regex:
166
+ * Running a specific test given a line number or a regex:
159
167
  ```bash
160
168
  bin/test test/models/trackable_test.rb:16
169
+ bin/test test/models/trackable_test.rb -n '/update.*record/'
161
170
  ```
162
171
 
163
172
  ## Starting with Rails?
@@ -172,18 +181,16 @@ Once you have solidified your understanding of Rails and authentication mechanis
172
181
 
173
182
  ## Getting started
174
183
 
175
- Devise 4.0 works with Rails 4.1 onwards. Add the following line to your Gemfile:
184
+ Devise 5 works with Rails 7 onwards. Run:
176
185
 
177
- ```ruby
178
- gem 'devise'
186
+ ```sh
187
+ bundle add devise
179
188
  ```
180
189
 
181
- Then run `bundle install`
182
-
183
190
  Next, you need to run the generator:
184
191
 
185
192
  ```console
186
- $ rails generate devise:install
193
+ rails generate devise:install
187
194
  ```
188
195
 
189
196
  At this point, a number of instructions will appear in the console. Among these instructions, you'll need to set up the default URL options for the Devise mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
@@ -198,7 +205,7 @@ The generator will install an initializer which describes ALL of Devise's config
198
205
  In the following command you will replace `MODEL` with the class name used for the application’s users (it’s frequently `User` but could also be `Admin`). This will create a model (if one does not exist) and configure it with the default Devise modules. The generator also configures your `config/routes.rb` file to point to the Devise controller.
199
206
 
200
207
  ```console
201
- $ rails generate devise MODEL
208
+ rails generate devise MODEL
202
209
  ```
203
210
 
204
211
  Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
@@ -370,7 +377,7 @@ We built Devise to help you quickly develop an application that uses authenticat
370
377
  Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after some time you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
371
378
 
372
379
  ```console
373
- $ rails generate devise:views
380
+ rails generate devise:views
374
381
  ```
375
382
 
376
383
  If you have more than one Devise model in your application (such as `User` and `Admin`), you will notice that Devise uses the same views for all models. Fortunately, Devise offers an easy way to customize views. All you need to do is set `config.scoped_views = true` inside the `config/initializers/devise.rb` file.
@@ -378,14 +385,14 @@ If you have more than one Devise model in your application (such as `User` and `
378
385
  After doing so, you will be able to have views based on the role like `users/sessions/new` and `admins/sessions/new`. If no view is found within the scope, Devise will use the default view at `devise/sessions/new`. You can also use the generator to generate scoped views:
379
386
 
380
387
  ```console
381
- $ rails generate devise:views users
388
+ rails generate devise:views users
382
389
  ```
383
390
 
384
391
  If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
385
392
  you can pass a list of views to the generator with the `-v` flag.
386
393
 
387
394
  ```console
388
- $ rails generate devise:views -v registrations confirmations
395
+ rails generate devise:views -v registrations confirmations
389
396
  ```
390
397
 
391
398
  ### Configuring controllers
@@ -395,7 +402,7 @@ If the customization at the views level is not enough, you can customize each co
395
402
  1. Create your custom controllers using the generator which requires a scope:
396
403
 
397
404
  ```console
398
- $ rails generate devise:controllers [scope]
405
+ rails generate devise:controllers [scope]
399
406
  ```
400
407
 
401
408
  If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
@@ -410,7 +417,7 @@ If the customization at the views level is not enough, you can customize each co
410
417
  ...
411
418
  end
412
419
  ```
413
- Use the `-c` flag to specify one or more controllers, for example: `rails generate devise:controllers users -c sessions`)
420
+ Use the `-c` flag to specify one or more controllers, for example: `rails generate devise:controllers users -c sessions`
414
421
 
415
422
  2. Tell the router to use this controller:
416
423
 
@@ -456,7 +463,7 @@ Devise also ships with default routes. If you need to customize them, you should
456
463
  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' }
457
464
  ```
458
465
 
459
- Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/main/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
466
+ Be sure to check `devise_for` [documentation](https://www.rubydoc.info/gems/devise/ActionDispatch/Routing/Mapper#devise_for-instance_method) for details.
460
467
 
461
468
  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:
462
469
 
@@ -486,7 +493,8 @@ Devise.setup do |config|
486
493
  # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
487
494
  # these new defaults that match Hotwire/Turbo behavior.
488
495
  # Note: These might become the new default in future versions of Devise.
489
- config.responder.error_status = :unprocessable_entity
496
+ config.responder.error_status = :unprocessable_content # for Rack 3.1 or higher
497
+ # config.responder.error_status = :unprocessable_entity # for Rack 3.0 or lower
490
498
  config.responder.redirect_status = :see_other
491
499
  end
492
500
  ```
@@ -646,7 +654,7 @@ Unlike controller tests, integration tests do not need to supply the
646
654
  `devise.mapping` `env` value, as the mapping can be inferred by the routes that
647
655
  are executed in your tests.
648
656
 
649
- You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
657
+ You can read more about testing your Rails controllers with RSpec in the wiki:
650
658
 
651
659
  * https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
652
660
 
@@ -693,9 +701,9 @@ Alternatively, you can simply run the Devise generator.
693
701
 
694
702
  Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
695
703
 
696
- ### ActiveJob Integration
704
+ ### Active Job Integration
697
705
 
698
- If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
706
+ If you are using Active Job to deliver Action Mailer messages in the
699
707
  background through a queuing back-end, you can send Devise emails through your
700
708
  existing queue by overriding the `send_devise_notification` method in your model.
701
709
 
@@ -707,7 +715,7 @@ end
707
715
 
708
716
  ### Password reset tokens and Rails logs
709
717
 
710
- If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/main/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
718
+ If you enable the [Recoverable](https://www.rubydoc.info/gems/devise/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:
711
719
 
712
720
  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.
713
721
  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.
@@ -759,14 +767,10 @@ Devise is based on Warden, which is a general Rack authentication framework crea
759
767
 
760
768
  https://github.com/wardencommunity/warden
761
769
 
762
- ### Contributors
763
-
764
- We have a long list of valued contributors. Check them all at:
765
-
766
- https://github.com/heartcombo/devise/graphs/contributors
767
-
768
770
  ## License
769
771
 
770
- MIT License. Copyright 2020-2024 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
772
+ MIT License.
773
+ Copyright 2020-2025 Rafael França, Carlos Antonio da Silva.
774
+ Copyright 2009-2019 Plataformatec.
771
775
 
772
776
  The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
@@ -27,7 +27,7 @@ class Devise::ConfirmationsController < DeviseController
27
27
  set_flash_message!(:notice, :confirmed)
28
28
  respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
29
29
  else
30
- # TODO: use `error_status` when the default changes to `:unprocessable_entity`.
30
+ # TODO: use `error_status` when the default changes to `:unprocessable_entity` / `:unprocessable_content`.
31
31
  respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
32
32
  end
33
33
  end
@@ -28,7 +28,7 @@ class Devise::SessionsController < DeviseController
28
28
  signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
29
29
  set_flash_message! :notice, :signed_out if signed_out
30
30
  yield if block_given?
31
- respond_to_on_destroy
31
+ respond_to_on_destroy(non_navigational_status: :no_content)
32
32
  end
33
33
 
34
34
  protected
@@ -62,7 +62,7 @@ class Devise::SessionsController < DeviseController
62
62
  if all_signed_out?
63
63
  set_flash_message! :notice, :already_signed_out
64
64
 
65
- respond_to_on_destroy
65
+ respond_to_on_destroy(non_navigational_status: :unauthorized)
66
66
  end
67
67
  end
68
68
 
@@ -72,11 +72,11 @@ class Devise::SessionsController < DeviseController
72
72
  users.all?(&:blank?)
73
73
  end
74
74
 
75
- def respond_to_on_destroy
75
+ def respond_to_on_destroy(non_navigational_status: :no_content)
76
76
  # We actually need to hardcode this as Rails default responder doesn't
77
77
  # support returning empty response on GET request
78
78
  respond_to do |format|
79
- format.all { head :no_content }
79
+ format.all { head non_navigational_status }
80
80
  format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status }
81
81
  end
82
82
  end
@@ -29,7 +29,7 @@ class Devise::UnlocksController < DeviseController
29
29
  set_flash_message! :notice, :unlocked
30
30
  respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
31
31
  else
32
- # TODO: use `error_status` when the default changes to `:unprocessable_entity`.
32
+ # TODO: use `error_status` when the default changes to `:unprocessable_entity` / `:unprocessable_content`.
33
33
  respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
34
34
  end
35
35
  end
@@ -1,30 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Keeping the helper around for backward compatibility.
3
4
  module DeviseHelper
4
- # Retain this method for backwards compatibility, deprecated in favor of modifying the
5
- # devise/shared/error_messages partial.
6
- def devise_error_messages!
7
- Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
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.
24
- DEPRECATION
25
-
26
- return "" if resource.errors.empty?
27
-
28
- render "devise/shared/error_messages", resource: resource
29
- end
30
5
  end
@@ -4,8 +4,8 @@
4
4
  <%= render "devise/shared/error_messages", resource: resource %>
5
5
 
6
6
  <div class="field">
7
- <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
7
+ <p><%= f.label :email %></p>
8
+ <p><%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %></p>
9
9
  </div>
10
10
 
11
11
  <div class="actions">
@@ -5,16 +5,16 @@
5
5
  <%= f.hidden_field :reset_password_token %>
6
6
 
7
7
  <div class="field">
8
- <%= f.label :password, "New password" %><br />
8
+ <p><%= f.label :password, "New password" %></p>
9
9
  <% if @minimum_password_length %>
10
- <em>(<%= @minimum_password_length %> characters minimum)</em><br />
10
+ <p><em>(<%= @minimum_password_length %> characters minimum)</em></p>
11
11
  <% end %>
12
- <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
12
+ <p><%= f.password_field :password, autofocus: true, autocomplete: "new-password" %></p>
13
13
  </div>
14
14
 
15
15
  <div class="field">
16
- <%= f.label :password_confirmation, "Confirm new password" %><br />
17
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
16
+ <p><%= f.label :password_confirmation, "Confirm new password" %></p>
17
+ <p><%= f.password_field :password_confirmation, autocomplete: "new-password" %></p>
18
18
  </div>
19
19
 
20
20
  <div class="actions">
@@ -4,12 +4,12 @@
4
4
  <%= render "devise/shared/error_messages", resource: resource %>
5
5
 
6
6
  <div class="field">
7
- <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
7
+ <p><%= f.label :email %></p>
8
+ <p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
9
9
  </div>
10
10
 
11
11
  <div class="actions">
12
- <%= f.submit "Send me reset password instructions" %>
12
+ <%= f.submit "Send me password reset instructions" %>
13
13
  </div>
14
14
  <% end %>
15
15
 
@@ -4,8 +4,8 @@
4
4
  <%= render "devise/shared/error_messages", resource: resource %>
5
5
 
6
6
  <div class="field">
7
- <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
7
+ <p><%= f.label :email %></p>
8
+ <p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
9
9
  </div>
10
10
 
11
11
  <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
@@ -13,22 +13,21 @@
13
13
  <% end %>
14
14
 
15
15
  <div class="field">
16
- <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
17
- <%= f.password_field :password, autocomplete: "new-password" %>
16
+ <p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i></p>
17
+ <p><%= f.password_field :password, autocomplete: "new-password" %></p>
18
18
  <% if @minimum_password_length %>
19
- <br />
20
- <em><%= @minimum_password_length %> characters minimum</em>
19
+ <p><em><%= @minimum_password_length %> characters minimum</em></p>
21
20
  <% end %>
22
21
  </div>
23
22
 
24
23
  <div class="field">
25
- <%= f.label :password_confirmation %><br />
26
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
24
+ <p><%= f.label :password_confirmation %></p>
25
+ <p><%= f.password_field :password_confirmation, autocomplete: "new-password" %></p>
27
26
  </div>
28
27
 
29
28
  <div class="field">
30
- <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
31
- <%= f.password_field :current_password, autocomplete: "current-password" %>
29
+ <p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i></p>
30
+ <p><%= f.password_field :current_password, autocomplete: "current-password" %></p>
32
31
  </div>
33
32
 
34
33
  <div class="actions">
@@ -4,21 +4,21 @@
4
4
  <%= render "devise/shared/error_messages", resource: resource %>
5
5
 
6
6
  <div class="field">
7
- <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
7
+ <p><%= f.label :email %></p>
8
+ <p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
9
9
  </div>
10
10
 
11
11
  <div class="field">
12
- <%= f.label :password %>
12
+ <p><%= f.label :password %></p>
13
13
  <% if @minimum_password_length %>
14
- <em>(<%= @minimum_password_length %> characters minimum)</em>
15
- <% end %><br />
16
- <%= f.password_field :password, autocomplete: "new-password" %>
14
+ <p><em>(<%= @minimum_password_length %> characters minimum)</em></p>
15
+ <% end %>
16
+ <p><%= f.password_field :password, autocomplete: "new-password" %></p>
17
17
  </div>
18
18
 
19
19
  <div class="field">
20
- <%= f.label :password_confirmation %><br />
21
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %>
20
+ <p><%= f.label :password_confirmation %></p>
21
+ <p><%= f.password_field :password_confirmation, autocomplete: "new-password" %></p>
22
22
  </div>
23
23
 
24
24
  <div class="actions">
@@ -2,19 +2,19 @@
2
2
 
3
3
  <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
4
  <div class="field">
5
- <%= f.label :email %><br />
6
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
5
+ <p><%= f.label :email %></p>
6
+ <p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
7
7
  </div>
8
8
 
9
9
  <div class="field">
10
- <%= f.label :password %><br />
11
- <%= f.password_field :password, autocomplete: "current-password" %>
10
+ <p><%= f.label :password %></p>
11
+ <p><%= f.password_field :password, autocomplete: "current-password" %></p>
12
12
  </div>
13
13
 
14
14
  <% if devise_mapping.rememberable? %>
15
15
  <div class="field">
16
- <%= f.check_box :remember_me %>
17
- <%= f.label :remember_me %>
16
+ <p><%= f.check_box :remember_me %></p>
17
+ <p><%= f.label :remember_me %></p>
18
18
  </div>
19
19
  <% end %>
20
20
 
@@ -1,5 +1,5 @@
1
1
  <% if resource.errors.any? %>
2
- <div id="error_explanation" data-turbo-cache="false">
2
+ <div id="error_explanation" data-turbo-temporary>
3
3
  <h2>
4
4
  <%= I18n.t("errors.messages.not_saved",
5
5
  count: resource.errors.count,
@@ -1,25 +1,25 @@
1
1
  <%- if controller_name != 'sessions' %>
2
- <%= link_to "Log in", new_session_path(resource_name) %><br />
2
+ <p><%= link_to "Log in", new_session_path(resource_name) %></p>
3
3
  <% end %>
4
4
 
5
5
  <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
- <%= link_to "Sign up", new_registration_path(resource_name) %><br />
6
+ <p><%= link_to "Sign up", new_registration_path(resource_name) %></p>
7
7
  <% end %>
8
8
 
9
9
  <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
10
- <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
10
+ <p><%= link_to "Forgot your password?", new_password_path(resource_name) %></p>
11
11
  <% end %>
12
12
 
13
13
  <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
- <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
14
+ <p><%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %></p>
15
15
  <% end %>
16
16
 
17
17
  <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
- <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
18
+ <p><%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %></p>
19
19
  <% end %>
20
20
 
21
21
  <%- if devise_mapping.omniauthable? %>
22
22
  <%- resource_class.omniauth_providers.each do |provider| %>
23
- <%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %><br />
23
+ <p><%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %></p>
24
24
  <% end %>
25
25
  <% end %>
@@ -4,8 +4,8 @@
4
4
  <%= render "devise/shared/error_messages", resource: resource %>
5
5
 
6
6
  <div class="field">
7
- <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
7
+ <p><%= f.label :email %></p>
8
+ <p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
9
9
  </div>
10
10
 
11
11
  <div class="actions">
@@ -37,16 +37,7 @@ module Devise
37
37
 
38
38
  expire_data_after_sign_in!
39
39
 
40
- if options[:bypass]
41
- Devise.deprecator.warn(<<-DEPRECATION.strip_heredoc, caller)
42
- [Devise] bypass option is deprecated and it will be removed in future version of Devise.
43
- Please use bypass_sign_in method instead.
44
- Example:
45
-
46
- bypass_sign_in(user)
47
- DEPRECATION
48
- warden.session_serializer.store(resource, scope)
49
- elsif warden.user(scope) == resource && !options.delete(:force)
40
+ if warden.user(scope) == resource && !options.delete(:force)
50
41
  # Do nothing. User already signed in and we are not forcing it.
51
42
  true
52
43
  else
@@ -106,12 +97,6 @@ module Devise
106
97
  private
107
98
 
108
99
  def expire_data_after_sign_in!
109
- # TODO: remove once Rails 5.2+ and forward are only supported.
110
- # session.keys will return an empty array if the session is not yet loaded.
111
- # This is a bug in both Rack and Rails.
112
- # A call to #empty? forces the session to be loaded.
113
- session.empty?
114
-
115
100
  session.keys.grep(/^devise\./).each { |k| session.delete(k) }
116
101
  end
117
102