Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

[Feature]Add missing associated user data to the session #23

Merged
merged 3 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added

- Provide user data via Koa Session

## [3.1.72] - 2020-10-16

Expand Down
8 changes: 7 additions & 1 deletion src/auth/create-oauth-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down