orbit-4-2/app/controllers/desktop/registrations_controller.rb

17 lines
633 B
Ruby
Raw Permalink Normal View History

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