Update devise to version 5.0 (#37419)

This commit is contained in:
Matt Jankowski
2026-02-05 06:05:32 -05:00
committed by GitHub
parent 9cd94168b3
commit f652c54c33
6 changed files with 18 additions and 16 deletions

View File

@@ -28,7 +28,7 @@ gem 'bootsnap', require: false
gem 'browser'
gem 'charlock_holmes', '~> 0.7.7'
gem 'chewy', '~> 7.3'
gem 'devise', '~> 4.9'
gem 'devise'
gem 'devise-two-factor'
group :pam_authentication, optional: true do

View File

@@ -187,10 +187,10 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
debug_inspector (1.2.0)
devise (4.9.4)
devise (5.0.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
railties (>= 7.0)
responders
warden (~> 1.2.3)
devise-two-factor (6.4.0)
@@ -965,7 +965,7 @@ DEPENDENCIES
csv (~> 3.2)
database_cleaner-active_record
debug (~> 1.8)
devise (~> 4.9)
devise
devise-two-factor
devise_pam_authenticatable2 (~> 9.2)
discard (~> 1.2)

View File

@@ -197,14 +197,14 @@ class Auth::SessionsController < Devise::SessionsController
"2fa_auth_attempts:#{user.id}:#{Time.now.utc.hour}"
end
def respond_to_on_destroy
def respond_to_on_destroy(**)
respond_to do |format|
format.json do
render json: {
redirect_to: after_sign_out_path_for(resource_name),
}, status: 200
end
format.all { super }
format.all { super(**) }
end
end
end

View File

@@ -105,11 +105,9 @@ Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
#
# Set explicitly to Rails default to avoid deprecation warnings.
# https://github.com/heartcombo/devise/pull/5645#issuecomment-1871849856
# Remove when Devise changes `SecretKeyFinder` to not emit deprecations.
config.secret_key = Rails.application.secret_key_base
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = '<%= SecureRandom.hex(64) %>'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,

View File

@@ -70,7 +70,7 @@ RSpec.describe Auth::SessionsController do
end
it 'shows a login error and does not log the user in' do
expect(flash[:alert]).to match I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
expect(flash[:alert]).to match(/#{failure_message_invalid_email}/i)
expect(controller.current_user).to be_nil
end
@@ -163,7 +163,7 @@ RSpec.describe Auth::SessionsController do
end
it 'shows a login error and does not log the user in' do
expect(flash[:alert]).to match I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
expect(flash[:alert]).to match(/#{failure_message_invalid_email}/i)
expect(controller.current_user).to be_nil
end
@@ -420,5 +420,9 @@ RSpec.describe Auth::SessionsController do
end
end
end
def failure_message_invalid_email
I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
end
end
end

View File

@@ -25,7 +25,7 @@ RSpec.describe 'Log in' do
it 'A invalid email and password user is not able to log in' do
fill_in_auth_details('invalid_email', 'invalid_password')
expect(subject).to have_css('.flash-message', text: failure_message('invalid'))
expect(subject).to have_css('.flash-message', text: /#{failure_message_invalid}/i)
end
context 'when confirmed at is nil' do
@@ -38,8 +38,8 @@ RSpec.describe 'Log in' do
end
end
def failure_message(message)
def failure_message_invalid
keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
I18n.t("devise.failure.#{message}", authentication_keys: keys.join('support.array.words_connector'))
I18n.t('devise.failure.invalid', authentication_keys: keys.join('support.array.words_connector'))
end
end