mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Update devise to version 5.0 (#37419)
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -28,7 +28,7 @@ gem 'bootsnap', '~> 1.18.0', require: false
|
|||||||
gem 'browser'
|
gem 'browser'
|
||||||
gem 'charlock_holmes', '~> 0.7.7'
|
gem 'charlock_holmes', '~> 0.7.7'
|
||||||
gem 'chewy', '~> 7.3'
|
gem 'chewy', '~> 7.3'
|
||||||
gem 'devise', '~> 4.9'
|
gem 'devise'
|
||||||
gem 'devise-two-factor'
|
gem 'devise-two-factor'
|
||||||
|
|
||||||
group :pam_authentication, optional: true do
|
group :pam_authentication, optional: true do
|
||||||
|
|||||||
@@ -184,10 +184,10 @@ GEM
|
|||||||
irb (~> 1.10)
|
irb (~> 1.10)
|
||||||
reline (>= 0.3.8)
|
reline (>= 0.3.8)
|
||||||
debug_inspector (1.2.0)
|
debug_inspector (1.2.0)
|
||||||
devise (4.9.4)
|
devise (5.0.0)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
railties (>= 4.1.0)
|
railties (>= 7.0)
|
||||||
responders
|
responders
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
devise-two-factor (6.2.0)
|
devise-two-factor (6.2.0)
|
||||||
@@ -954,7 +954,7 @@ DEPENDENCIES
|
|||||||
csv (~> 3.2)
|
csv (~> 3.2)
|
||||||
database_cleaner-active_record
|
database_cleaner-active_record
|
||||||
debug (~> 1.8)
|
debug (~> 1.8)
|
||||||
devise (~> 4.9)
|
devise
|
||||||
devise-two-factor
|
devise-two-factor
|
||||||
devise_pam_authenticatable2 (~> 9.2)
|
devise_pam_authenticatable2 (~> 9.2)
|
||||||
discard (~> 1.2)
|
discard (~> 1.2)
|
||||||
|
|||||||
@@ -197,14 +197,14 @@ class Auth::SessionsController < Devise::SessionsController
|
|||||||
"2fa_auth_attempts:#{user.id}:#{Time.now.utc.hour}"
|
"2fa_auth_attempts:#{user.id}:#{Time.now.utc.hour}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_on_destroy
|
def respond_to_on_destroy(**)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
render json: {
|
render json: {
|
||||||
redirect_to: after_sign_out_path_for(resource_name),
|
redirect_to: after_sign_out_path_for(resource_name),
|
||||||
}, status: 200
|
}, status: 200
|
||||||
end
|
end
|
||||||
format.all { super }
|
format.all { super(**) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -105,11 +105,9 @@ Devise.setup do |config|
|
|||||||
# The secret key used by Devise. Devise uses this key to generate
|
# The secret key used by Devise. Devise uses this key to generate
|
||||||
# random tokens. Changing this key will render invalid all existing
|
# random tokens. Changing this key will render invalid all existing
|
||||||
# confirmation, reset password and unlock tokens in the database.
|
# confirmation, reset password and unlock tokens in the database.
|
||||||
#
|
# Devise will use the `secret_key_base` as its `secret_key`
|
||||||
# Set explicitly to Rails default to avoid deprecation warnings.
|
# by default. You can change it below and use your own secret key.
|
||||||
# https://github.com/heartcombo/devise/pull/5645#issuecomment-1871849856
|
# config.secret_key = '<%= SecureRandom.hex(64) %>'
|
||||||
# Remove when Devise changes `SecretKeyFinder` to not emit deprecations.
|
|
||||||
config.secret_key = Rails.application.secret_key_base
|
|
||||||
|
|
||||||
# ==> Mailer Configuration
|
# ==> Mailer Configuration
|
||||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ RSpec.describe Auth::SessionsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'shows a login error and does not log the user in' do
|
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
|
expect(controller.current_user).to be_nil
|
||||||
end
|
end
|
||||||
@@ -163,7 +163,7 @@ RSpec.describe Auth::SessionsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'shows a login error and does not log the user in' do
|
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
|
expect(controller.current_user).to be_nil
|
||||||
end
|
end
|
||||||
@@ -420,5 +420,9 @@ RSpec.describe Auth::SessionsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def failure_message_invalid_email
|
||||||
|
I18n.t('devise.failure.invalid', authentication_keys: I18n.t('activerecord.attributes.user.email'))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ RSpec.describe 'Log in' do
|
|||||||
it 'A invalid email and password user is not able to 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')
|
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
|
end
|
||||||
|
|
||||||
context 'when confirmed at is nil' do
|
context 'when confirmed at is nil' do
|
||||||
@@ -38,8 +38,8 @@ RSpec.describe 'Log in' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def failure_message(message)
|
def failure_message_invalid
|
||||||
keys = User.authentication_keys.map { |key| User.human_attribute_name(key) }
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user