diff --git a/CHANGELOG.md b/CHANGELOG.md index 5272e319..17a587f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/app/helpers/devise_helper.rb b/app/helpers/devise_helper.rb index b9101e04..0bfcb063 100644 --- a/app/helpers/devise_helper.rb +++ b/app/helpers/devise_helper.rb @@ -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 diff --git a/lib/devise.rb b/lib/devise.rb index 4fec8a0e..0336ed70 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -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' diff --git a/lib/devise/controllers/sign_in_out.rb b/lib/devise/controllers/sign_in_out.rb index fa29bbfc..7e053d11 100644 --- a/lib/devise/controllers/sign_in_out.rb +++ b/lib/devise/controllers/sign_in_out.rb @@ -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 diff --git a/lib/devise/test/controller_helpers.rb b/lib/devise/test/controller_helpers.rb index aba2bb44..d3522a34 100644 --- a/lib/devise/test/controller_helpers.rb +++ b/lib/devise/test/controller_helpers.rb @@ -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) diff --git a/lib/devise/test_helpers.rb b/lib/devise/test_helpers.rb deleted file mode 100644 index cc9ef424..00000000 --- a/lib/devise/test_helpers.rb +++ /dev/null @@ -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 diff --git a/test/controllers/custom_strategy_test.rb b/test/controllers/custom_strategy_test.rb index d352a15b..1c968126 100644 --- a/test/controllers/custom_strategy_test.rb +++ b/test/controllers/custom_strategy_test.rb @@ -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