Shopify / shopify-app-template-node

MIT License
867 stars 391 forks source link

How to handle scope changes? #1246

Closed mariusa closed 1 year ago

mariusa commented 1 year ago

Because the node template app is using shopify-app-express, it's hard to figure out how using other frameworks (fastify instead of express) should work.

eg handling scope changes in template app works almost fine (the old app front-end loads briefly, then user is redirected to approve scope change).

But grep scope has no results in template code. How is this handled?

Tried to do it in app.get('/api/auth', but that loads inside an iframe and shopify.auth.begin gets stuck on redirects when app is embedded (works fine for non-embedded)

mkevinosullivan commented 1 year ago

@mariusa There's a non-supported app_template_fastify branch that should be a Fastify version of the default Node template app. Hopefully that will help.

In terms of your specific question, it's the call to the session.isActive() method here that compares the configured scopes against the scopes of the session - if they're the same, the processing continues inside the if clause, if not, it continues beyond the if clause and redirects through auth again.

(The equivalent line inside the shopify-app-express package.)

mariusa commented 1 year ago

Thanks for session.isActive() clarification and Fastify template!