Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Move forbidden/unnauthorized outsode of Spree Frontend

Damian Legawiecb9cb5b1a787b
diff --git a/core/app/controllers/spree/errors_controller.rb b/core/app/controllers/spree/errors_controller.rb
new file mode 100644
index 0000000000..c296649008
--- /dev/null
+++ b/core/app/controllers/spree/errors_controller.rb
@@ -0,0 +1,11 @@
+module Spree
+ class ErrorsController < BaseController
+ def forbidden
+ render status: 403
+ end
+
+ def unauthorized
+ render status: 401
+ end
+ end
+end
diff --git a/frontend/app/views/spree/shared/forbidden.html.erb b/core/app/views/spree/errors/forbidden.html.erb
similarity index 100%
rename from frontend/app/views/spree/shared/forbidden.html.erb
rename to core/app/views/spree/errors/forbidden.html.erb
diff --git a/frontend/app/views/spree/shared/unauthorized.html.erb b/core/app/views/spree/errors/unauthorized.html.erb
similarity index 100%
rename from frontend/app/views/spree/shared/unauthorized.html.erb
rename to core/app/views/spree/errors/unauthorized.html.erb
diff --git a/core/config/routes.rb b/core/config/routes.rb
index 98125a5fef..9117b9cd3d 100644
--- a/core/config/routes.rb
+++ b/core/config/routes.rb
@@ -1,5 +1,6 @@
Spree::Core::Engine.add_routes do
- get '/forbidden', to: 'home#forbidden', as: :forbidden
+ get '/forbidden', to: 'errors#forbidden', as: :forbidden
+ get '/unauthorized', to: 'errors#unauthorized', as: :unauthorized
end
Spree::Core::Engine.draw_routes
diff --git a/frontend/app/controllers/spree/store_controller.rb b/frontend/app/controllers/spree/store_controller.rb
index ef8a197148..16c5e9ea82 100644
--- a/frontend/app/controllers/spree/store_controller.rb
+++ b/frontend/app/controllers/spree/store_controller.rb
@@ -4,14 +4,6 @@ module Spree
skip_before_action :verify_authenticity_token, only: :ensure_cart, raise: false
- def forbidden
- render 'spree/shared/forbidden', layout: Spree::Config[:layout], status: 403
- end
-
- def unauthorized
- render 'spree/shared/unauthorized', layout: Spree::Config[:layout], status: 401
- end
-
def account_link
render partial: 'spree/shared/link_to_account'
fresh_when(try_spree_current_user)
diff --git a/frontend/config/routes.rb b/frontend/config/routes.rb
index 12531e7699..e7bbdec1c0 100644
--- a/frontend/config/routes.rb
+++ b/frontend/config/routes.rb
@@ -26,7 +26,6 @@ Spree::Core::Engine.add_routes do
get '/t/*id', to: 'taxons#show', as: :nested_taxons
get '/product_carousel/:id', to: 'taxons#product_carousel'
- get '/unauthorized', to: 'home#unauthorized', as: :unauthorized
get '/content/cvv', to: 'content#cvv', as: :cvv
get '/content/test', to: 'content#test'
get '/cart_link', to: 'store#cart_link', as: :cart_link