User Choose his role on signup

Hello, i want to make the user choose his role on sign up but the sign up function does not allow to do that and when i use hooks to update the user. after hook is not working with social signin it works good with email but not social how to make it with social.
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");
}
}
})
},
1 Reply
OSMX
OSMXOP2mo ago
the after hook triggered when i begin redirected to google choose account page when i still don't have any info how to fix that

Did you find this page helpful?