I have a user_id attached to the Store model for a Shopify App. I want to be able to have a user login with their user account to have the shopify session start instead of using needing to open the app from their app section of their store. This is a standalone app btw.
I have tried this for when users sign in:
if Shop.find_by(user_id: current_user)
shop = Shop.find_by(user_id: current_user)
shop = ShopifyAPI::Session.new(shop.shopify_domain, shop.shopify_token)
ShopifyAPI::Base.activate_session(shop)
end
and:
if Shop.find_by(user_id: current_user)
shop = Shop.find_by(user_id: current_user)
shop = ShopifyApp::SessionRepository.retrieve(shop.id)
ShopifyAPI::Base.activate_session(shop)
end
I tried this in my session create method and as a after_action callback for the create method in the sessions controller...
Is there something I am doing wrong?
I tested this in console to make sure all of the assocations were correct. The token and shopify_domain are all there attached to the user