Skip to content

Commit

Permalink
fix pageMiddleware receiving a commonContext, not the user context (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens authored Nov 27, 2022
1 parent f911ce5 commit 1bdfe37
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/lib/server/createAdminUIMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function defaultIsAccessAllowed({ session, sessionStrategy }: KeystoneContext) {

export function createAdminUIMiddlewareWithNextApp(
config: KeystoneConfig,
context: KeystoneContext,
commonContext: KeystoneContext,
nextApp: NextApp
) {
const handle = nextApp.getRequestHandler();
Expand All @@ -55,8 +55,8 @@ export function createAdminUIMiddlewareWithNextApp(
return;
}

const userContext = await context.withRequest(req, res);
const isValidSession = await isAccessAllowed(userContext); // TODO: rename "isValidSession" to "wasAccessAllowed"?
const context = await commonContext.withRequest(req, res);
const isValidSession = await isAccessAllowed(context); // TODO: rename "isValidSession" to "wasAccessAllowed"?
const shouldRedirect = await pageMiddleware?.({
context,
isValidSession,
Expand Down

1 comment on commit 1bdfe37

@vercel
Copy link

@vercel vercel bot commented on 1bdfe37 Nov 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.