Skip to content

Instantly share code, notes, and snippets.

@whitmanc
Last active September 23, 2016 23:48
Show Gist options
  • Save whitmanc/2fa1ffa1587ba24f796305449918cebf to your computer and use it in GitHub Desktop.
Save whitmanc/2fa1ffa1587ba24f796305449918cebf to your computer and use it in GitHub Desktop.
Spree (3.1.0) - Custom redirect after admin login
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