fix: catch and log failed email attempts

This commit is contained in:
Henry
2026-02-20 15:42:07 +00:00
parent 8a9cb8fabf
commit 71ecf2e6d3

View File

@@ -7,8 +7,8 @@ import * as memberRepo from "@kan/db/repository/member.repo";
import * as subscriptionRepo from "@kan/db/repository/subscription.repo"; import * as subscriptionRepo from "@kan/db/repository/subscription.repo";
import * as userRepo from "@kan/db/repository/user.repo"; import * as userRepo from "@kan/db/repository/user.repo";
import * as workspaceRepo from "@kan/db/repository/workspace.repo"; import * as workspaceRepo from "@kan/db/repository/workspace.repo";
import { generateUID } from "@kan/shared/utils";
import { sendEmail } from "@kan/email"; import { sendEmail } from "@kan/email";
import { generateUID } from "@kan/shared/utils";
import { createStripeClient } from "@kan/stripe"; import { createStripeClient } from "@kan/stripe";
import { socialProvidersPlugin } from "./providers"; import { socialProvidersPlugin } from "./providers";
@@ -139,7 +139,8 @@ export function createPlugins(db: dbClient) {
let newSlug = workspace.publicId; let newSlug = workspace.publicId;
if (workspace.slug !== workspace.publicId) { if (workspace.slug !== workspace.publicId) {
const isPublicIdAvailable = await workspaceRepo.isWorkspaceSlugAvailable( const isPublicIdAvailable =
await workspaceRepo.isWorkspaceSlugAvailable(
db, db,
workspace.publicId, workspace.publicId,
); );
@@ -172,6 +173,7 @@ export function createPlugins(db: dbClient) {
magicLink({ magicLink({
expiresIn: 60 * 60 * 24 * 7, // 7 days expiresIn: 60 * 60 * 24 * 7, // 7 days
sendMagicLink: async ({ email, url }) => { sendMagicLink: async ({ email, url }) => {
try {
const decodedUrl = decodeURIComponent(url); const decodedUrl = decodeURIComponent(url);
console.log("Sending magic link to:", email, "URL:", url); console.log("Sending magic link to:", email, "URL:", url);
console.log( console.log(
@@ -236,6 +238,13 @@ export function createPlugins(db: dbClient) {
}, },
); );
} }
} catch (error) {
console.error("Error sending magic link:", {
email,
url,
error,
});
}
}, },
}), }),
// Generic OIDC provider // Generic OIDC provider