correct user passwd and sent json to front-end

This commit is contained in:
Rueshyna 2012-11-30 15:17:39 +08:00 committed by chris
parent 8a7ae3f061
commit 184f903b1c
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
class Desktop::RegistrationsController < Devise::RegistrationsController
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
render json: {success:true, msg: "Password successfully update!"}.to_json
else
clean_up_passwords(resource)
error_msg = resource.errors.full_messages.join("<br />")
render :json => {success: false, msg: error_msg}.to_json
end
end
end