Skip to content

Commit

Permalink
Remove deprecated options argument from update methods
Browse files Browse the repository at this point in the history
They were added to support an old/deprecated feature of Rails, as the
message was saying, we can now remove them from the code as well.
  • Loading branch information
carlosantoniodasilva committed Oct 13, 2023
1 parent 49e4a99 commit 63939c1
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions lib/devise/models/database_authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,7 @@ def clean_up_passwords
# users to change relevant information like the e-mail without changing
# their password). In case the password field is rejected, the confirmation
# is also rejected as long as it is also blank.
def update_with_password(params, *options)
if options.present?
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
[Devise] The second argument of `DatabaseAuthenticatable#update_with_password`
(`options`) is deprecated and it will be removed in the next major version.
It was added to support a feature deprecated in Rails 4, so you can safely remove it
from your code.
DEPRECATION
end

def update_with_password(params)
current_password = params.delete(:current_password)

if params[:password].blank?
Expand All @@ -102,9 +93,9 @@ def update_with_password(params, *options)
end

result = if valid_password?(current_password)
update(params, *options)
update(params)
else
assign_attributes(params, *options)
assign_attributes(params)
valid?
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
Expand All @@ -121,25 +112,16 @@ def update_with_password(params, *options)
#
# Example:
#
# def update_without_password(params, *options)
# def update_without_password(params)
# params.delete(:email)
# super(params)
# end
#
def update_without_password(params, *options)
if options.present?
Devise.deprecator.warn <<-DEPRECATION.strip_heredoc
[Devise] The second argument of `DatabaseAuthenticatable#update_without_password`
(`options`) is deprecated and it will be removed in the next major version.
It was added to support a feature deprecated in Rails 4, so you can safely remove it
from your code.
DEPRECATION
end

def update_without_password(params)
params.delete(:password)
params.delete(:password_confirmation)

result = update(params, *options)
result = update(params)
clean_up_passwords
result
end
Expand Down

0 comments on commit 63939c1

Please sign in to comment.