hooks: {
after: createAuthMiddleware(async (ctx) => {
// Handle sign up hook.
if (ctx.query?.signup) {
try {
const role = ctx.query.role as UserRole;
const response = await fetchSignup({
userId: ctx.context.newSession?.user.id!,
firstName: ctx.context.newSession?.user.name?.split(" ")[0] || "",
lastName: ctx.context.newSession?.user.name?.split(" ")[1] || "",
role,
timezone: ctx.query.timezone!,
});
} catch (error) {
console.error("Error during signup:", error);
throw new APIError("EXPECTATION_FAILED");
}
}
})
},
hooks: {
after: createAuthMiddleware(async (ctx) => {
// Handle sign up hook.
if (ctx.query?.signup) {
try {
const role = ctx.query.role as UserRole;
const response = await fetchSignup({
userId: ctx.context.newSession?.user.id!,
firstName: ctx.context.newSession?.user.name?.split(" ")[0] || "",
lastName: ctx.context.newSession?.user.name?.split(" ")[1] || "",
role,
timezone: ctx.query.timezone!,
});
} catch (error) {
console.error("Error during signup:", error);
throw new APIError("EXPECTATION_FAILED");
}
}
})
},