I added a couple lines of code to the shopify_login_protection.rb file to carry the Product ID through the login process as a session variable, for the first time a user visits my app each time. That way my app still knows what product page they came from after they’ve logged in. New code is in bold below:
module ShopifyLoginProtection
def shopify_session
if session[:shopify]
begin
# session[:shopify] set in LoginController#finalize
ActiveResource::Base.site = session[:shopify].site
yield
ensure
ActiveResource::Base.site = nil
end
else
session[:return_to] = request.path
if params[:id]
session[:product_id] = params[:id]
end
redirect_to :controller => 'login'
end
end
def current_shop
session[:shopify]
end
end
@Josh,
Another option would have been:
module ShopifyLoginProtection
def shopify_session
if session[:shopify]
begin
# session[:shopify] set in LoginController#finalize
ActiveResource::Base.site = session[:shopify].site
yield
ensure
ActiveResource::Base.site = nil
end
else
session[:return_to] = request.request_uri
redirect_to :controller => 'login'
end
end
def current_shop
session[:shopify]
end
end
This would have preserved the product_id param and any other query params that were part of that url.
Subject | Author | Latest Post |
---|---|---|
Subject | Author | Posted |
---|---|---|
yesterday | ||
yesterday | ||
yesterday | ||
yesterday | ||
yesterday |
User | Count |
---|---|
34 | |
32 | |
22 | |
16 | |
16 |