Update session on hooks

Hello everyone, I'm trying to update a session (only if the user logged in with google or github) this is the code
const auth = betterAuth({
  hooks: {
    after: createAuthMiddleware(async (ctx) => {
      if (ctx.path === '/callback/:id') {
        if (ctx.params?.id === 'google') {
          const session = await getSessionFromCtx(ctx)
          console.log(session) // output: is null
          console.log(ctx.context.session) // output: is null

          await ctx.context.internalAdapter.updateSession(
            session!.session.id,
            {
              ...ctx.
            }
          )
        }
        else if (ctx.params?.id === 'github') {
          console.log('github callback, attaching wallet....')
        }
      }
    }),
  }
  ...
})


session
and
ctx.context.session
are always null.... how can I update the session if the user came from social login?
Was this page helpful?