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);
}
}
}
})
},
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);
}
}
}
})
},