From e1ef8b6f8056627aa0859b8a2e6038cd20adc8fa Mon Sep 17 00:00:00 2001 From: Babken Mesropyan Date: Fri, 3 Jul 2020 14:58:53 +0400 Subject: [PATCH 1/5] Add missing data to session ## Description Fixes (#1540) This adds associated_user_scope and associated_user which is stated in Shopify [documentation](https://shopify.dev/tutorials/authenticate-with-oauth#step-3-confirm-installation). ## Type of change - [x] @shopify/koa-shopify-auth Patch: Bug (non-breaking change which fixes an issue)expected) ## Checklist - [x] I have added a changelog entry, prefixed by the type of change noted above (Documentation fix and Test update does not need a changelog as we do not publish new version) --- .../koa-shopify-auth/src/auth/create-oauth-callback.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts index 918c0d6e9d..8a5c7c01c4 100644 --- a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts +++ b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts @@ -53,11 +53,17 @@ export default function createOAuthCallback(config: AuthConfig) { } const accessTokenData = await accessTokenResponse.json(); - const {access_token: accessToken} = accessTokenData; - + const { + access_token: accessToken, + associated_user_scope: associatedUserScope, + associated_user: associatedUser } = accessTokenData; + + if (ctx.session) { ctx.session.shop = shop; ctx.session.accessToken = accessToken; + ctx.session.associatedUserScope = associatedUserScope; + ctx.session.associatedUser = associatedUser; } ctx.state.shopify = { From 29dd2efabd1951f2ea87b81ea0f26561743058a6 Mon Sep 17 00:00:00 2001 From: Babken Mesropyan Date: Fri, 3 Jul 2020 15:37:23 +0400 Subject: [PATCH 2/5] Fix spacing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inserted `,⏎···` prettier/prettier Deleted `····⏎····` prettier/prettier --- packages/koa-shopify-auth/src/auth/create-oauth-callback.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts index 8a5c7c01c4..ad823783b2 100644 --- a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts +++ b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts @@ -56,8 +56,8 @@ export default function createOAuthCallback(config: AuthConfig) { const { access_token: accessToken, associated_user_scope: associatedUserScope, - associated_user: associatedUser } = accessTokenData; - + associated_user: associatedUser + } = accessTokenData; if (ctx.session) { ctx.session.shop = shop; From fdfe23d067268a2580c4a9cc47faf9376efcbbf9 Mon Sep 17 00:00:00 2001 From: Babken Mesropyan Date: Fri, 3 Jul 2020 15:56:15 +0400 Subject: [PATCH 3/5] Update create-oauth-callback.ts --- packages/koa-shopify-auth/src/auth/create-oauth-callback.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts index ad823783b2..5d6c39009d 100644 --- a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts +++ b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts @@ -53,11 +53,9 @@ export default function createOAuthCallback(config: AuthConfig) { } const accessTokenData = await accessTokenResponse.json(); - const { - access_token: accessToken, + const {access_token: accessToken, associated_user_scope: associatedUserScope, - associated_user: associatedUser - } = accessTokenData; + associated_user: associatedUser} = accessTokenData; if (ctx.session) { ctx.session.shop = shop; From 691c7e9cc1b9550d7a662e7a8070b0ad2969f4e0 Mon Sep 17 00:00:00 2001 From: Babken Mesropyan Date: Mon, 6 Jul 2020 21:28:35 +0400 Subject: [PATCH 4/5] Update packages/koa-shopify-auth/src/auth/create-oauth-callback.ts Co-authored-by: Tim Anema --- packages/koa-shopify-auth/src/auth/create-oauth-callback.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts index 5d6c39009d..d69661fe8b 100644 --- a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts +++ b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts @@ -53,9 +53,11 @@ export default function createOAuthCallback(config: AuthConfig) { } const accessTokenData = await accessTokenResponse.json(); - const {access_token: accessToken, + const { + access_token: accessToken, associated_user_scope: associatedUserScope, - associated_user: associatedUser} = accessTokenData; + associated_user: associatedUser + } = accessTokenData; if (ctx.session) { ctx.session.shop = shop; From 8d2a2e84d26dc491018ac067f736f74242be9abc Mon Sep 17 00:00:00 2001 From: Babken Mesropyan Date: Mon, 13 Jul 2020 18:01:48 +0400 Subject: [PATCH 5/5] Update packages/koa-shopify-auth/src/auth/create-oauth-callback.ts Co-authored-by: Tim Anema --- packages/koa-shopify-auth/src/auth/create-oauth-callback.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts index d69661fe8b..a8b8bdfc36 100644 --- a/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts +++ b/packages/koa-shopify-auth/src/auth/create-oauth-callback.ts @@ -56,9 +56,9 @@ export default function createOAuthCallback(config: AuthConfig) { const { access_token: accessToken, associated_user_scope: associatedUserScope, - associated_user: associatedUser + associated_user: associatedUser, } = accessTokenData; - + if (ctx.session) { ctx.session.shop = shop; ctx.session.accessToken = accessToken;