app/controllers/users_controller.rb in spree-0.7.1 vs app/controllers/users_controller.rb in spree-0.8.0
- old
+ new
@@ -1,24 +1,39 @@
class UsersController < Spree::BaseController
+ resource_controller
-# before_filter :login_required, :except => [:new, :create]
+ before_filter :require_no_user, :only => [:new, :create]
+ before_filter :require_user, :only => [:show, :edit, :update]
before_filter :initialize_extension_partials
+ ssl_required :new, :create, :edit, :update, :show
- resource_controller
actions :all, :except => [:index, :destroy]
-
+
+ create do
+ flash nil
+ wants.html { redirect_back_or_default products_path }
+ wants.js { render :js => true.to_json }
+ failure.wants.html { render :new }
+ failure.wants.js { render :js => @user.errors.to_json }
+ end
+
show.before do
@orders = Order.checkout_completed(true).find_all_by_user_id(current_user.id)
end
-
- create do
- flash nil
- wants.html { redirect_back_or_default(products_path) }
+
+ def update
+ @user = @current_user
+ if @user.update_attributes(params[:user])
+ flash[:notice] = t("account_updated")
+ redirect_to account_url
+ else
+ render :action => :edit
+ end
end
-
- create.after do
- @user.roles << Role.find_by_name("user")
- @user.save
- self.current_user = @user
- end
-
+
+
+ private
+ def object
+ @object ||= current_user
+ end
+
end