Last active
September 23, 2016 23:48
-
-
Save whitmanc/2fa1ffa1587ba24f796305449918cebf to your computer and use it in GitHub Desktop.
Spree (3.1.0) - Custom redirect after admin login
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
Spree::UserSessionsController.class_eval do | |
def redirect_back_or_default(default) | |
if spree_current_user && spree_current_user.has_spree_role?("admin") | |
redirect_to(admin_products_path) | |
# Commenting out line below to allow redirecting to | |
# admin/products page | |
#redirect_to(session["spree_user_return_to"] || default) | |
session["spree_user_return_to"] = nil | |
else | |
redirect_to(default) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment