Starting to rework login behaviour when hitting /admin

This commit is contained in:
Will Marshall
2014-05-20 15:47:00 +10:00
parent 2fc45d635d
commit df82627bd1
4 changed files with 22 additions and 3 deletions

View File

@@ -26,7 +26,11 @@ class CheckoutController < Spree::CheckoutController
if @order.next
state_callback(:after)
else
flash[:error] = @order.errors.full_messages.to_sentence
unless @order.errors.empty?
flash[:error] = @order.errors.full_messages.to_sentence
else
flash[:error] = t(:payment_processing_failed)
end
update_failed
return
end

View File

@@ -11,4 +11,4 @@ Spree::Admin::BaseController.class_eval do
authorize! :admin, record
authorize! action, record
end
end
end

View File

@@ -4,4 +4,17 @@ Spree::Admin::OverviewController.class_eval do
@product_count = Spree::Product.active.managed_by(spree_current_user).count
@order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count
end
end
# This is in Spree::Core::ControllerHelpers::Auth
# But you can't easily reopen modules in Ruby
def unauthorized
if try_spree_current_user
flash[:error] = t(:authorization_failure)
redirect_to '/unauthorized'
else
store_location
url = respond_to?(:spree_login_path) ? spree_login_path : root_path
redirect_to url
end
end
end

View File

@@ -1,6 +1,8 @@
Openfoodnetwork::Application.routes.draw do
root :to => 'home#index'
get "/#/login", to: "home#index", as: :spree_login
resource :shop, controller: "shop" do
get :products
post :order_cycle