lib/spree/auth/engine.rb in solidus_auth_devise-1.2.2 vs lib/spree/auth/engine.rb in solidus_auth_devise-1.2.3

- old
+ new

@@ -43,26 +43,30 @@ Rails.configuration.cache_classes ? require(c) : load(c) end end ApplicationController.send :include, Spree::AuthenticationHelpers - Spree::BaseController.unauthorized_redirect = -> do - if try_spree_current_user - flash[:error] = Spree.t(:authorization_failure) - redirect_to spree.unauthorized_path - else - store_location - redirect_to spree.login_path + if self.frontend_available? + Spree::BaseController.unauthorized_redirect = -> do + if try_spree_current_user + flash[:error] = Spree.t(:authorization_failure) + redirect_to spree.unauthorized_path + else + store_location + redirect_to spree.login_path + end end end - Spree::Admin::BaseController.unauthorized_redirect = -> do - if try_spree_current_user - flash[:error] = Spree.t(:authorization_failure) - redirect_to spree.admin_unauthorized_path - else - store_location - redirect_to spree.admin_login_path + if self.backend_available? + Spree::Admin::BaseController.unauthorized_redirect = -> do + if try_spree_current_user + flash[:error] = Spree.t(:authorization_failure) + redirect_to spree.admin_unauthorized_path + else + store_location + redirect_to spree.admin_login_path + end end end end def self.backend_available?