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

31 lines
772 B
Ruby
Raw Normal View History

2011-03-06 18:28:00 +00:00
class UsersController < Devise::RegistrationsController
2011-03-27 19:44:15 +00:00
def edit
render_with_scope :edit
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]
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-03-27 19:44:15 +00:00
render(:json => 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