Make copy of resource only for update action

This commit is contained in:
Chase DuBois 2011-04-23 00:08:09 +08:00 committed by José Valim
parent e26c8ce499
commit fd8e34650e
1 changed files with 6 additions and 4 deletions

View File

@ -35,7 +35,11 @@ class Devise::RegistrationsController < ApplicationController
end
# PUT /resource
# We need to use a copy of the resource because we don't want to change
# the current user in place.
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
if resource.update_with_password(params[resource_name])
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
@ -102,11 +106,9 @@ class Devise::RegistrationsController < ApplicationController
end
end
# Authenticates the current scope and gets a copy of the current resource.
# We need to use a copy because we don't want actions like update changing
# the current user in place.
# Authenticates the current scope and gets the current resource from the session.
def authenticate_scope!
send(:"authenticate_#{resource_name}!", true)
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
self.resource = send(:"current_#{resource_name}")
end
end