summaryrefslogtreecommitdiff
path: root/src/routes/magicLink.ts
diff options
context:
space:
mode:
authorRaphael Kabo <mail@raphaelkabo.com>2025-05-28 18:32:47 +0100
committerRaphael Kabo <mail@raphaelkabo.com>2025-05-28 18:32:47 +0100
commita6f8ec770d06ce33042ed3f222cba786897e0233 (patch)
treea060e72668de41fcbeae5e891ee86b096b096f26 /src/routes/magicLink.ts
parent08fa2f616c90e59066d0308097c65c424b5b4a88 (diff)
parentfd637b405c8784a07dabd54b10fda98ad9f4a4ad (diff)
Merge remote-tracking branch 'origin/main' into clearer-editing-mode
Diffstat (limited to 'src/routes/magicLink.ts')
-rw-r--r--src/routes/magicLink.ts27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/routes/magicLink.ts b/src/routes/magicLink.ts
index b4afca6..1e0f87b 100644
--- a/src/routes/magicLink.ts
+++ b/src/routes/magicLink.ts
@@ -1,9 +1,9 @@
import { Router, Request, Response } from "express";
import { frontendConfig } from "../lib/config.js";
-import { sendEmailFromTemplate } from "../lib/email.js";
import { generateMagicLinkToken } from "../util/generator.js";
import MagicLink from "../models/MagicLink.js";
import { getConfigMiddleware } from "../lib/middleware.js";
+import i18next from "i18next";
const router = Router();
@@ -16,7 +16,7 @@ router.post("/magic-link/event/create", async (req: Request, res: Response) => {
...frontendConfig(res),
message: {
type: "danger",
- text: "Please provide an email address.",
+ text: i18next.t("routes.magiclink.provideemail"),
},
});
return;
@@ -31,7 +31,7 @@ router.post("/magic-link/event/create", async (req: Request, res: Response) => {
...frontendConfig(res),
message: {
type: "success",
- text: "Thanks! If this email address can create events, you should receive an email with a magic link.",
+ text: i18next.t("routes.magiclink.thanks"),
},
});
return;
@@ -48,24 +48,19 @@ router.post("/magic-link/event/create", async (req: Request, res: Response) => {
// Take this opportunity to delete any expired magic links
await MagicLink.deleteMany({ expiryTime: { $lt: new Date() } });
- sendEmailFromTemplate(
- email,
- "",
- `Magic link to create an event`,
- "createEventMagicLink",
- {
- token,
- siteName: res.locals.config?.general.site_name,
- siteLogo: res.locals.config?.general.email_logo_url,
- domain: res.locals.config?.general.domain,
+ req.emailService.sendEmailFromTemplate({
+ to: email,
+ subject: i18next.t("routes.magiclink.mailsubject"),
+ templateName: "createEventMagicLink",
+ templateData: {
+ token
},
- req,
- );
+ });
res.render("createEventMagicLink", {
...frontendConfig(res),
message: {
type: "success",
- text: "Thanks! If this email address can create events, you should receive an email with a magic link.",
+ text: i18next.t("routes.magiclink.thanks"),
},
});
});