2011-03-06 18:28:00 +00:00
|
|
|
class UsersController < Devise::RegistrationsController
|
2011-03-27 19:44:15 +00:00
|
|
|
def edit
|
2013-12-02 21:47:02 +00:00
|
|
|
render("sidebar/edit_profile", :layout => "sidebar")
|
2011-03-27 19:44:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2013-12-02 12:07:18 +00:00
|
|
|
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
|
|
|
|
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
|
|
|
|
if update_resource(resource, account_update_params)
|
|
|
|
yield resource if block_given?
|
2013-12-02 21:47:02 +00:00
|
|
|
sign_in(resource_name, resource, :bypass => true)
|
2011-09-15 01:35:22 +00:00
|
|
|
flash[:notice] = "Profile updated!"
|
2013-12-02 21:47:02 +00:00
|
|
|
redirect_to(:controller => "sidebar", :action => "search")
|
2011-03-27 19:44:15 +00:00
|
|
|
else
|
|
|
|
clean_up_passwords(resource)
|
2013-12-02 21:47:02 +00:00
|
|
|
render(:json => {:errors => resource.errors}, :status => 500)
|
2011-03-27 19:44:15 +00:00
|
|
|
end
|
|
|
|
end
|
2011-03-06 18:28:00 +00:00
|
|
|
|
|
|
|
def create
|
2013-12-02 12:07:18 +00:00
|
|
|
build_resource(sign_up_params)
|
2011-03-06 18:28:00 +00:00
|
|
|
if resource.save
|
2013-12-02 12:07:18 +00:00
|
|
|
yield resource if block_given?
|
2011-05-08 08:29:21 +00:00
|
|
|
sign_in(resource_name, resource)
|
2013-12-02 21:47:02 +00:00
|
|
|
render(:json => resource)
|
2011-03-06 18:28:00 +00:00
|
|
|
else
|
|
|
|
clean_up_passwords(resource)
|
2013-12-02 21:47:02 +00:00
|
|
|
render(:json => {:errors => resource.errors}, :status => 500)
|
2011-03-06 18:28:00 +00:00
|
|
|
end
|
|
|
|
end
|
2012-11-15 17:34:19 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2013-12-02 12:07:18 +00:00
|
|
|
def sign_up_params
|
|
|
|
params.require(:user).permit(:email, :name, :organization, :password, :password_confirmation, :sms_number, :voice_number)
|
2012-11-15 17:34:19 +00:00
|
|
|
end
|
2013-12-02 12:07:18 +00:00
|
|
|
|
|
|
|
def account_update_params
|
|
|
|
params.require(:user).permit(:address_1, :address_2, :city, :current_password, :email, :name, :organization, :password, :password_confirmation, :remember_me, :sms_number, :state, :voice_number, :zip)
|
|
|
|
end
|
|
|
|
|
2011-03-06 18:28:00 +00:00
|
|
|
end
|