class Sprangular::AccountsController < Sprangular::BaseController
  before_filter :check_authorization, except: :create

  def create
    @user = Spree::User.create(spree_user_params)

    if @user.persisted?
      sign_in(:spree_user, @user)
      @order = current_order

      render 'show'
    else
      invalid_resource!(@user)
    end
  end

  def show
    authorize! :show, @user
    @order = current_order
  end

  def update
    authorize! :update, @user
    @user.update_attributes spree_user_params

    if @user.valid?
      @order = current_order

      render 'show'
    else
      invalid_resource!(@user)
    end
  end

private

  def spree_user_params
    params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
  end
end

class Sprangular::AccountsController < Sprangular::BaseController
  before_filter :check_authorization, except: :create

  def create
    @user = Spree::User.create(spree_user_params)

    sign_in(:spree_user, @user) if @user.persisted?
    @order = current_order

    render 'show'
  end

  def show
    authorize! :show, @user
    @order = current_order
  end

  def update
    authorize! :update, @user
    @user.update_attributes spree_user_params
    @order = current_order

    render 'show'
  end

private

  def spree_user_params
    params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
  end
end

--- 
+++ 
@@ -4,10 +4,14 @@
   def create
     @user = Spree::User.create(spree_user_params)
 
-    sign_in(:spree_user, @user) if @user.persisted?
-    @order = current_order
+    if @user.persisted?
+      sign_in(:spree_user, @user)
+      @order = current_order
 
-    render 'show'
+      render 'show'
+    else
+      invalid_resource!(@user)
+    end
   end
 
   def show
@@ -18,9 +22,14 @@
   def update
     authorize! :update, @user
     @user.update_attributes spree_user_params
-    @order = current_order
 
-    render 'show'
+    if @user.valid?
+      @order = current_order
+
+      render 'show'
+    else
+      invalid_resource!(@user)
+    end
   end
 
 private
Fix error handling for POST/PUT to /account
