mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Make copy of resource only for update action
This commit is contained in:
parent
e26c8ce499
commit
fd8e34650e
1 changed files with 6 additions and 4 deletions
|
@ -35,7 +35,11 @@ class Devise::RegistrationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# PUT /resource
|
# 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
|
def update
|
||||||
|
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
|
||||||
|
|
||||||
if resource.update_with_password(params[resource_name])
|
if resource.update_with_password(params[resource_name])
|
||||||
set_flash_message :notice, :updated if is_navigational_format?
|
set_flash_message :notice, :updated if is_navigational_format?
|
||||||
sign_in resource_name, resource, :bypass => true
|
sign_in resource_name, resource, :bypass => true
|
||||||
|
@ -102,11 +106,9 @@ class Devise::RegistrationsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Authenticates the current scope and gets a copy of the current resource.
|
# Authenticates the current scope and gets the current resource from the session.
|
||||||
# We need to use a copy because we don't want actions like update changing
|
|
||||||
# the current user in place.
|
|
||||||
def authenticate_scope!
|
def authenticate_scope!
|
||||||
send(:"authenticate_#{resource_name}!", true)
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue