I am using Next.js and Convex Auth. I want to create a stripe customer on signup. I tried the following logic:
//page.ts
onSubmit={async (e) => {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
formData.set("flow", flow);
await void signIn("password", formData)
.catch((error) => {
setError(error.message);
})
.then(() => {
onSignUp();
})
.then(() => {
router.push("/");
});
}}
And then onSignUp:
export const onSignUp = action({
args: {},
handler: async (ctx, args) => {
const userId = await getAuthUserId(ctx);
if (!userId) throw new Error("User not found");
// Rest of the logic goes here
},
});
The issue is that the users is not authenticated by the time I want to invoke the onSignUp Action.
Am I implementing it wrong, or do I need to go about it a different way? What is the best way to create a user flow upon a user signing up?