-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Unauthorized Redirect patch autoloadable
- Loading branch information
Showing
3 changed files
with
25 additions
and
13 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/decorators/controllers/alchemy/solidus/spree_admin_base_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Alchemy | ||
module Solidus | ||
module SpreeAdminBaseControllerDecorator | ||
def self.prepended(base) | ||
if Alchemy.user_class_name == "::Alchemy::User" | ||
base.unauthorized_redirect = -> do | ||
if spree_current_user | ||
flash[:error] = I18n.t('spree.authorization_failure') | ||
redirect_to spree.root_path | ||
else | ||
store_location | ||
redirect_to Alchemy.login_path | ||
end | ||
end | ||
end | ||
end | ||
|
||
if defined?(::Spree::Admin::BaseController) | ||
::Spree::Admin::BaseController.prepend self | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.