Remove deprecated stuff (#5803)

All of these have been deprecated for years, if we're releasing a new
major version, let's take the opportunity to do some cleanup.

* Remove deprecated `:bypass` option from `sign_in` helper,
  use `bypass_sign_in` instead.
* Remove deprecated `devise_error_messages!` helper,
  use `render "devise/shared/error_messages", resource: resource` instead.
* Remove deprecated `scope` second argument from `sign_in(resource, :admin)`
  controller test helper, use `sign_in(resource, scope: :admin)` instead.
* Remove deprecated `Devise::TestHelpers`,
  use `Devise::Test::ControllerHelpers` instead.

Closes #5739
This commit is contained in:
Carlos Antonio da Silva
2025-10-31 13:52:34 -03:00
committed by GitHub
parent fa052e5064
commit b0867c998c
7 changed files with 9 additions and 66 deletions

View File

@@ -3,6 +3,10 @@
* breaking changes
* Drop support to Ruby < 2.7
* Drop support to Rails < 7.0
* Remove deprecated `:bypass` option from `sign_in` helper, use `bypass_sign_in` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `devise_error_messages!` helper, use `render "devise/shared/error_messages", resource: resource` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `scope` second argument from `sign_in(resource, :admin)` controller test helper, use `sign_in(resource, scope: :admin)` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `Devise::TestHelpers`, use `Devise::Test::ControllerHelpers` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove `SecretKeyFinder` and use `app.secret_key_base` as the default secret key for `Devise.secret_key` if a custom `Devise.secret_key` is not provided.
This is potentially a breaking change because Devise previously used the following order to find a secret key:
@@ -12,8 +16,7 @@
```
Now, it always uses `application.secret_key_base`. Make sure you're using the same secret key after the upgrade; otherwise, previously generated tokens for `recoverable`, `lockable`, and `confirmable` will be invalid.
https://github.com/heartcombo/devise/pull/5645
[#5645](https://github.com/heartcombo/devise/pull/5645)
* enhancements
* Removed deprecations warning output for `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` (@soartec-lab)
* Add Rails 8 support.

View File

@@ -1,30 +1,5 @@
# frozen_string_literal: true
# Keeping the helper around for backward compatibility.
module DeviseHelper
# Retain this method for backwards compatibility, deprecated in favor of modifying the
# devise/shared/error_messages partial.
def devise_error_messages!
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
[Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be
removed in the next major version.
Devise now uses a partial under "devise/shared/error_messages" to display
error messages by default, and make them easier to customize. Update your
views changing calls from:
<%= devise_error_messages! %>
to:
<%= render "devise/shared/error_messages", resource: resource %>
To start customizing how errors are displayed, you can copy the partial
from devise to your `app/views` folder. Alternatively, you can run
`rails g devise:views` which will copy all of them again to your app.
DEPRECATION
return "" if resource.errors.empty?
render "devise/shared/error_messages", resource: resource
end
end

View File

@@ -16,7 +16,6 @@ module Devise
autoload :Orm, 'devise/orm'
autoload :ParameterFilter, 'devise/parameter_filter'
autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
autoload :TestHelpers, 'devise/test_helpers'
autoload :TimeInflector, 'devise/time_inflector'
autoload :TokenGenerator, 'devise/token_generator'

View File

@@ -37,16 +37,7 @@ module Devise
expire_data_after_sign_in!
if options[:bypass]
Devise.deprecator.warn(<<-DEPRECATION.strip_heredoc, caller)
[Devise] bypass option is deprecated and it will be removed in future version of Devise.
Please use bypass_sign_in method instead.
Example:
bypass_sign_in(user)
DEPRECATION
warden.session_serializer.store(resource, scope)
elsif warden.user(scope) == resource && !options.delete(:force)
if warden.user(scope) == resource && !options.delete(:force)
# Do nothing. User already signed in and we are not forcing it.
true
else

View File

@@ -64,17 +64,7 @@ module Devise
#
# sign_in users(:alice)
# sign_in users(:alice), scope: :admin
def sign_in(resource, deprecated = nil, scope: nil)
if deprecated.present?
scope = resource
resource = deprecated
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
[Devise] sign_in(:#{scope}, resource) on controller tests is deprecated and will be removed from Devise.
Please use sign_in(resource, scope: :#{scope}) instead.
DEPRECATION
end
def sign_in(resource, scope: nil)
scope ||= Devise::Mapping.find_scope!(resource)
warden.instance_variable_get(:@users).delete(scope)

View File

@@ -1,15 +0,0 @@
# frozen_string_literal: true
module Devise
module TestHelpers
def self.included(base)
base.class_eval do
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
[Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise.
For controller tests, please include `Devise::Test::ControllerHelpers` instead.
DEPRECATION
include Devise::Test::ControllerHelpers
end
end
end
end

View File

@@ -3,7 +3,7 @@
require 'test_helper'
require 'ostruct'
require 'warden/strategies/base'
require 'devise/test_helpers'
require 'devise/test/controller_helpers'
class CustomStrategyController < ActionController::Base
def new