Open joelvh opened 1 year ago
We are able to work around this in some cases by calling await login(request)
if the shop
querystring parameter is not the same as the session.shop
. However, this seems like the behavior that likely ought to be built-in.
Hey, thanks for reporting this! Unfortunately we do need the cookie because that's how we keep track of which user is making requests in a non-embedded scenario.
That being said, I agree that the package should detect this scenario and update the cookie automatically when the user logs in with a second shop, though your suggested workaround with login
is the correct way to solve this.
Since this is a little bit of an edge case and there is a workaround for it, it might be a while until we can actually fix it.
hi @paulomarg, thanks for weighing in. Can you confirm that -- in effect -- you're saying this package assumes users only belong to one shop and won't login to the same app from different shops?
I'm asking mostly for posterity of this thread to make sure the edge case in question is clear to others. Thanks!
Yes, right now that is a limitation of this package, but it only affects non-embedded apps. For embedded apps, because we never store a cookie and use session tokens provided by the admin interface, this would not be an issue.
So just to set expectations here, we are going to look into ways of improving the behaviour, but there are other things that will take priority over it!
Thanks for the clarification @paulomarg!
This is also affecting my application. Thanks for the workaround @joelvh!
We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.
You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.
Any update for this?
We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.
You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.
Issue summary
In our standalone Remix app (not embedded), we use
await authenticate.admin(request)
to create a session (offline). This sets a cookie and the user's session has the auth token for the shop they accessed our app from.However, if the same user accesses our app from another shop, the cookie retrieves a session for the previous shop -- thereby referencing the wrong session information and access token. The cookie also still states
cookies: 'shopify_app_session=offline_previous-shop.myshopify.com;
.This same thing happens with online sessions. The
authenticate.admin
function doesn't ensure that theshop
querystring parameter is used for session storage and retrieval, to handle the same user accessing the same app from multiple shops.Is there a way to prevent a cookie from being set, to make these requests stateless?
Expected behavior
authenticate.admin
should retrieve session data based on the shop the request originated from (e.g. respect theshop
querystring parameter)Actual behavior
hmac
andshop
parameters indicating they are accessing from a different shopSteps to reproduce the problem
const { session } = await authenticate.admin(request)
to initiate a session when accessing the app homepagesession
object to see what shop it holds information forsession
has Shop 1 datasession
still has Shop 1 data