adopt-a-hydrant/app/controllers/users_controller.rb

33 lines
827 B
Ruby
Raw Normal View History

2011-03-06 18:28:00 +00:00
class UsersController < Devise::RegistrationsController
2011-05-06 02:38:25 +00:00
respond_to :json, :only => [:create]
2011-03-27 19:44:15 +00:00
def edit
render("edit", :layout => "info_window")
2011-03-27 19:44:15 +00:00
end
def update
if resource.update_with_password(params[resource_name])
sign_in(resource_name, resource, :bypass => true)
redirect_to(:controller => "hydrants", :action => "show", :hydrant_id => params[:hydrant_id])
2011-03-27 19:44:15 +00:00
else
clean_up_passwords(resource)
render(:json => {"errors" => resource.errors})
end
end
2011-03-06 18:28:00 +00:00
def create
build_resource
if resource.save
if resource.active?
sign_in(resource_name, resource)
else
expire_session_data_after_sign_in!
end
2011-05-06 02:38:25 +00:00
respond_with resource
2011-03-06 18:28:00 +00:00
else
clean_up_passwords(resource)
2011-03-07 02:40:29 +00:00
render(:json => {"errors" => resource.errors})
2011-03-06 18:28:00 +00:00
end
end
end