Skip to content

Commit 04c4108

Browse files
Move sign_in_after_change_password? to protected
While not much practical change, it hopefully shows better the intention that it's a method users can override if they need, similar to a few other methods in controllers. Also move `update_needs_confirmation?` down to private, as this one in particular I don't think we intended to allow overriding, as it has no practical behavior change other than the flash message.
1 parent f8a02b0 commit 04c4108

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

app/controllers/devise/passwords_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def assert_reset_token_passed
6969
end
7070
end
7171

72-
# Check if the user should be signed in automatically after resetting the password
72+
# Check if the user should be signed in automatically after resetting the password.
7373
def sign_in_after_reset_password?
7474
resource_class.sign_in_after_reset_password
7575
end

app/controllers/devise/registrations_controller.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ def cancel
8282

8383
protected
8484

85-
def update_needs_confirmation?(resource, previous)
86-
resource.respond_to?(:pending_reconfirmation?) &&
87-
resource.pending_reconfirmation? &&
88-
previous != resource.unconfirmed_email
89-
end
90-
9185
# By default we want to require a password checks on update.
9286
# You can overwrite this method in your own RegistrationsController.
9387
def update_resource(resource, params)
@@ -133,6 +127,13 @@ def authenticate_scope!
133127
self.resource = send(:"current_#{resource_name}")
134128
end
135129

130+
# Check if the user should be signed in automatically after updating the password.
131+
def sign_in_after_change_password?
132+
return true if account_update_params[:password].blank?
133+
134+
resource_class.sign_in_after_change_password
135+
end
136+
136137
def sign_up_params
137138
devise_parameter_sanitizer.sanitize(:sign_up)
138139
end
@@ -160,9 +161,9 @@ def set_flash_message_for_update(resource, prev_unconfirmed_email)
160161
set_flash_message :notice, flash_key
161162
end
162163

163-
def sign_in_after_change_password?
164-
return true if account_update_params[:password].blank?
165-
166-
resource_class.sign_in_after_change_password
164+
def update_needs_confirmation?(resource, previous)
165+
resource.respond_to?(:pending_reconfirmation?) &&
166+
resource.pending_reconfirmation? &&
167+
previous != resource.unconfirmed_email
167168
end
168169
end

0 commit comments

Comments
 (0)