How to make an "after" hook when using Google Sign in?

We have an after hook which does various things from a sign up survey the user submits.

It works well when email and password is used. When the user selects Google sign up, then that hook never runs.

It's something like this:

  hooks: {
    after: createAuthMiddleware(async (ctx) => {

      // Hook into signup process to create organization and assign role
      if (
        ctx.path.startsWith('/sign-up') ||
        ctx.path.startsWith('/on-boarding') ||
        ctx.path.startsWith('/login') ||
        ctx.path.includes('/callback/google')
      ) {
        const newSession = ctx.context.newSession;
        if (newSession) {
          try {
            console.log(
              'Better Auth After Signup Hook - Creating organization for user:',
              newSession.user.id
            );
          } catch (error) {
            console.error('Error in after signup hook:', error);
          }
        }
      }
    })
  },


How can we make it run when Google is used to signup?
Was this page helpful?