Skip to content

Open source alternative to Semrush and Ahrefs

Send Loops contacts after email verification (#189)

Ben Senescufa20de2126e6
diff --git a/src/lib/auth.ts b/src/lib/auth.ts
index eb0ba2bb..b28b756a 100644
--- a/src/lib/auth.ts
+++ b/src/lib/auth.ts
@@ -9,7 +9,7 @@ import { getOrCreateDefaultHostedOrganization } from "@/server/auth/default-host
import {
sendHostedPasswordResetEmail,
sendHostedVerificationEmail,
- upsertHostedSignupContact,
+ upsertHostedVerifiedContact,
} from "@/server/email/loops";
const hostedBaseUrlSchema = z
@@ -55,32 +55,31 @@ function createAuth() {
confirmationUrl: url,
});
},
- },
- trustedOrigins: getTrustedOrigins(baseUrl),
- database: drizzleAdapter(db, {
- provider: "sqlite",
- }),
- plugins: [...baseAuthConfig.plugins, tanstackStartCookies()],
- databaseHooks: {
- user: {
- create: {
- after: async (user) => {
+ afterEmailVerification: async (user) => {
try {
- await upsertHostedSignupContact({
+ await upsertHostedVerifiedContact({
userId: user.id,
email: user.email,
name: user.name,
});
} catch (error) {
- console.error("Failed to create Loops profile for signup:", {
- userId: user.id,
- email: user.email,
- error,
- });
+ console.error(
+ "Failed to sync Loops profile after verification:",
+ {
+ userId: user.id,
+ email: user.email,
+ error,
+ },
+ );
}
},
},
- },
+ trustedOrigins: getTrustedOrigins(baseUrl),
+ database: drizzleAdapter(db, {
+ provider: "sqlite",
+ }),
+ plugins: [...baseAuthConfig.plugins, tanstackStartCookies()],
+ databaseHooks: {
session: {
create: {
before: async (session) => {
diff --git a/src/server/email/loops.ts b/src/server/email/loops.ts
index 86a3c40a..d4cc3970 100644
--- a/src/server/email/loops.ts
+++ b/src/server/email/loops.ts
@@ -91,7 +91,7 @@ function getContactNameParts(name: string | null | undefined) {
};
}
-export async function upsertHostedSignupContact({
+export async function upsertHostedVerifiedContact({
userId,
email,
name,
@@ -104,7 +104,7 @@ export async function upsertHostedSignupContact({
if (!apiKey) {
console.warn(
- "Skipping Loops signup contact sync: LOOPS_API_KEY is not set",
+ "Skipping Loops verified contact sync: LOOPS_API_KEY is not set",
);
return;
}
@@ -129,14 +129,14 @@ export async function upsertHostedSignupContact({
}
const errorPayload = await response.json().catch(() => null);
- console.error("Loops signup contact sync error:", {
+ console.error("Loops verified contact sync error:", {
status: response.status,
email,
userId,
errorPayload,
});
- throw new Error(`Failed to sync Loops signup contact (${response.status})`);
+ throw new Error(`Failed to sync Loops verified contact (${response.status})`);
}
export async function sendHostedVerificationEmail({