Hooks - session and newSession are both `null` after signin

I'm using an after hook to run some middleware after signing in a user. The user is able to sign in successfully, however both the session and newSession objects in the context are null.

What's going on here?

My expectation is that newSession would be defined with the new session for the signed-in user.

hooks: {
  after: createAuthMiddleware(async (ctx) => {
    if (ctx.path.startsWith('/sign-in')) {
      // Why are these both `null`?
      console.log('[Auth] new session:', ctx.context.newSession)
      console.log('[Auth] session:', ctx.context.session)
    }
  }),
},
Was this page helpful?