Skip to content

Commit

Permalink
convert session to an instance so we can call isActive on it
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSecurityDev committed Jan 12, 2022
1 parent f2369ba commit c6c8b54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-koa-shopify-auth",
"version": "1.0.3",
"version": "1.0.4",
"description": "A better, simplified version of the (no longer supported) @Shopify/koa-shopify-auth middleware library. It removes the use of cookies for sessions (which greatly smooths the auth process), replaces a deprecated API call, and supports v2 of the official @shopify/shopify-api package.",
"author": "TheSecurityDev",
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion src/verify-request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Shopify from "@shopify/shopify-api";
import { Session } from "@shopify/shopify-api/dist/auth/session";
import { HttpResponseError } from "@shopify/shopify-api/dist/error";
import { Context, Next } from "koa";

Expand Down Expand Up @@ -30,11 +31,13 @@ export default function verifyRequest(options?: VerifyRequestOptions) {
};

return async function verifyTokenMiddleware(ctx: Context, next: Next) {
const session = await Shopify.Utils.loadCurrentSession(
const sessionData = await Shopify.Utils.loadCurrentSession(
ctx.req,
ctx.res,
accessMode === "online"
);
// Create session instance from loaded session data (if available), so we can call isActive() method on it
const session = sessionData ? Session.cloneSession(sessionData, sessionData.id) : null;

const { query } = ctx;
const shop = query.shop ? query.shop.toString() : "";
Expand Down

0 comments on commit c6c8b54

Please sign in to comment.