Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Session scope check fails when scope is undefined #159

Closed
axmachina opened this issue Apr 9, 2021 · 1 comment · Fixed by #169
Closed

Session scope check fails when scope is undefined #159

axmachina opened this issue Apr 9, 2021 · 1 comment · Fixed by #169

Comments

@axmachina
Copy link

Issue summary

This fails when session is present with scope undefined.

``
if (session) {
const scopesChanged = !Shopify.Context.SCOPES.equals(session.scope);

  if (!scopesChanged && session.accessToken && (!session.expires || session.expires >= new Date())) {
    ctx.cookies.set(TOP_LEVEL_OAUTH_COOKIE_NAME);
    await next();
    return;
  }
}

``

Expected behavior

Should invalidate session and initiate oauth.

Actual behavior

What actually happens?

The failure happens downstream in shopify api,

TypeError: Cannot read property 'map' of undefined at new AuthScopes (/node_modules/@shopify/shopify-api/dist/auth/scopes/index.js:14:35)

Steps to reproduce the problem

I'm unable to reproduce this reliably, but can manually remove scope from session to test.

@carmelal carmelal transferred this issue from Shopify/koa-shopify-auth Apr 9, 2021
@carmelal
Copy link
Contributor

carmelal commented Apr 9, 2021

Hi @axmachina, thank you for bringing this up. I've moved this issue to the shopify-node-api repo to help us keep track of it - this is where the underlying issue is, and we're currently working on a solution.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
3 participants