Skip to content

Commit

Permalink
Move controller decorators into Spree::Auth namespace (#565)
Browse files Browse the repository at this point in the history
This way we're avoiding any conflicts from developer apps using `Spree::SomeControllerDecorator`
  • Loading branch information
damianlegawiec authored Apr 5, 2022
1 parent 0a45ca0 commit 6623f53
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Spree::Admin::BaseControllerDecorator
module Spree::Auth::Admin::BaseControllerDecorator
# Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
# Override this method in your controllers if you want to have special behavior in case the user is not authorized
# to access the requested action. For example, a popup window might simply close itself.
Expand All @@ -22,4 +22,4 @@ def model_class
nil
end
end
Spree::Admin::BaseController.prepend(Spree::Admin::BaseControllerDecorator)
::Spree::Admin::BaseController.prepend(Spree::Auth::Admin::BaseControllerDecorator)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Spree::Admin::Orders::CustomerDetailsControllerDecorator
module Spree::Auth::Admin::Orders::CustomerDetailsControllerDecorator

def self.prepended(base)
base.before_action :check_authorization
Expand All @@ -17,4 +17,4 @@ def check_authorization
authorize! action, resource, session[:access_token]
end
end
Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Admin::Orders::CustomerDetailsControllerDecorator)
Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Auth::Admin::Orders::CustomerDetailsControllerDecorator)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Spree::Admin::OrdersControllerDecorator
module Spree::Auth::Admin::OrdersControllerDecorator

def self.prepended(base)
base.before_action :check_authorization
Expand All @@ -22,4 +22,4 @@ def check_authorization
end
end
end
Spree::Admin::OrdersController.prepend(Spree::Admin::OrdersControllerDecorator)
Spree::Admin::OrdersController.prepend(Spree::Auth::Admin::OrdersControllerDecorator)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Spree::Auth::Admin::ResourceControllerDecorator
def self.prepended(base)
base.rescue_from CanCan::AccessDenied, with: :unauthorized
end
end
Spree::Admin::ResourceController.prepend(Spree::Auth::Admin::ResourceControllerDecorator)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spree/core/validators/email' if Spree.version.to_f < 3.5
module Spree::CheckoutControllerDecorator
module Spree::Auth::CheckoutControllerDecorator
def self.prepended(base)
base.before_action :check_authorization
base.before_action :check_registration, except: [:registration, :update_registration]
Expand Down Expand Up @@ -42,4 +42,4 @@ def check_registration
redirect_to spree.checkout_registration_path
end
end
Spree::CheckoutController.prepend(Spree::CheckoutControllerDecorator)
Spree::CheckoutController.prepend(Spree::Auth::CheckoutControllerDecorator)

0 comments on commit 6623f53

Please sign in to comment.