sendVerificationOTP: createAuthEndpoint(
"/email-otp/send-verification-otp",
{
...
},
async (ctx) => {
...
if (opts.disableSignUp) {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
throw new APIError("BAD_REQUEST", {
message: ERROR_CODES.USER_NOT_FOUND,
});
}
} else if (ctx.body.type === "forget-password") {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
return ctx.json({
success: true,
});
}
}
await options.sendVerificationOTP(
{
email,
otp,
type: ctx.body.type,
},
ctx.request,
);
});
sendVerificationOTP: createAuthEndpoint(
"/email-otp/send-verification-otp",
{
...
},
async (ctx) => {
...
if (opts.disableSignUp) {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
throw new APIError("BAD_REQUEST", {
message: ERROR_CODES.USER_NOT_FOUND,
});
}
} else if (ctx.body.type === "forget-password") {
const user = await ctx.context.internalAdapter.findUserByEmail(email);
if (!user) {
return ctx.json({
success: true,
});
}
}
await options.sendVerificationOTP(
{
email,
otp,
type: ctx.body.type,
},
ctx.request,
);
});