fix: signup (#25334)
* Handle Stripe logic in `paymentCallback` * Remove endpoint * Do not send email verification email if premium username * Remove logic from verify-view * Callback send verification email * Add `create` method to `VerificationToken` repository * Create `VerificationTokenService` * Early return if payment failed * Refactor token generation * Add tests * Type fixes * Type fixes
This commit is contained in:
1 parent
06348982a3
commit
e5ebf7feb4
12 files changed
+714
-104
No files matched your search
@@ -12,7 +12,10 @@ const transporter = nodemailer.createTransport<TransportOptions>({
|
||||
...(serverConfig.transport as TransportOptions),
|
||||
} as TransportOptions);
|
||||
|
||||
const sendVerificationRequest = async ({ identifier, url }: SendVerificationRequestParams) => {
|
||||
const sendVerificationRequest = async ({
|
||||
identifier,
|
||||
url,
|
||||
}: Pick<SendVerificationRequestParams, "identifier" | "url">) => {
|
||||
const emailsDir = path.resolve(process.cwd(), "..", "..", "packages/emails", "templates");
|
||||
const originalUrl = new URL(url);
|
||||
const webappUrl = new URL(process.env.NEXTAUTH_URL || WEBAPP_URL);
|
||||
|
||||
@@ -213,11 +213,15 @@ const handler: CustomNextApiHandler = async (body, usernameStatus) => {
|
||||
if (process.env.AVATARAPI_USERNAME && process.env.AVATARAPI_PASSWORD) {
|
||||
await prefillAvatar({ email });
|
||||
}
|
||||
sendEmailVerification({
|
||||
email,
|
||||
language: await getLocaleFromRequest(buildLegacyRequest(await headers(), await cookies())),
|
||||
username: username || "",
|
||||
});
|
||||
// Only send verification email for non-premium usernames
|
||||
// Premium usernames will get a magic link after payment in paymentCallback
|
||||
if (!checkoutSessionId) {
|
||||
sendEmailVerification({
|
||||
email,
|
||||
language: await getLocaleFromRequest(buildLegacyRequest(await headers(), await cookies())),
|
||||
username: username || "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (checkoutSessionId) {
|
||||
|
||||
Reference in new issue
Block a user