diff --git a/server/lib/login/passwordless/start.ts b/server/lib/login/passwordless/start.ts
index 522ad64..18f0b7b 100644
--- a/server/lib/login/passwordless/start.ts
+++ b/server/lib/login/passwordless/start.ts
@@ -1,10 +1,18 @@
+import { buildTemplate } from 'lib/email/build-template';
import { emailToId } from 'lib/email/to-id';
import { sendMail } from 'lib/email/send';
import * as storage from 'node-persist';
import { Accownt } from 'types/accownt';
import { signJWT } from 'lib/jwt/sign';
-const { TEMP_JWT_EXPIRES_IN, ACCOWNT_API_URL, STORAGE, NAME } = process.enve;
+const {
+ PASSWORDLESS_LOGIN_HTML_TEMPLATE,
+ PASSWORDLESS_LOGIN_TEXT_TEMPLATE,
+ TEMP_JWT_EXPIRES_IN,
+ ACCOWNT_API_URL,
+ STORAGE,
+ NAME
+} = process.enve;
export async function startPasswordlessLogin(
email: Accownt.User['email']
@@ -17,8 +25,18 @@ export async function startPasswordlessLogin(
const link = `${ACCOWNT_API_URL}/login/passwordless?jwt=${token}`;
await sendMail({
subject: `${NAME} Passwordless Login`,
- html: `Login to ${NAME}.`,
- text: link,
+ html: await buildTemplate({
+ name: 'LINK',
+ file: PASSWORDLESS_LOGIN_HTML_TEMPLATE,
+ value: link,
+ fallback: 'Login.'
+ }),
+ text: await buildTemplate({
+ name: 'LINK',
+ file: PASSWORDLESS_LOGIN_TEXT_TEMPLATE,
+ value: link,
+ fallback: 'Login: %LINK%"'
+ }),
to: user.email
});
diff --git a/server/lib/register/start.ts b/server/lib/register/start.ts
index 18f8c07..d7e23d4 100644
--- a/server/lib/register/start.ts
+++ b/server/lib/register/start.ts
@@ -1,3 +1,4 @@
+import { buildTemplate } from 'lib/email/build-template';
import { setPassword } from 'lib/account/set-password';
import { checkEmail } from 'lib/register/check-email';
import { cleanEmail } from 'lib/email/clean';
@@ -9,6 +10,8 @@ import * as qs from 'qs';
import axios from 'axios';
const {
+ EMAIL_VERIFICATION_HTML_TEMPLATE,
+ EMAIL_VERIFICATION_TEXT_TEMPLATE,
TEMP_JWT_EXPIRES_IN,
ACCOWNT_API_URL,
RECAPTCHA_KEY,
@@ -56,8 +59,18 @@ export async function startRegistration(
const link = `${ACCOWNT_API_URL}/register?jwt=${token}`;
await sendMail({
subject: `${NAME} Email Verification`,
- html: `Verify my email.`,
- text: link,
+ html: await buildTemplate({
+ name: 'LINK',
+ file: EMAIL_VERIFICATION_HTML_TEMPLATE,
+ value: link,
+ fallback: 'Verify my email.'
+ }),
+ text: await buildTemplate({
+ name: 'LINK',
+ file: EMAIL_VERIFICATION_TEXT_TEMPLATE,
+ value: link,
+ fallback: 'Verify your email: %LINK%"'
+ }),
to: email
});
diff --git a/types/accownt.d.ts b/types/accownt.d.ts
index a9f4410..26fbc70 100644
--- a/types/accownt.d.ts
+++ b/types/accownt.d.ts
@@ -112,6 +112,32 @@ export namespace Accownt {
* @example "1h"
*/
TEMP_JWT_EXPIRES_IN: string;
+ /**
+ * Path to a file containing the template for the text-only version of
+ * the email/account verification message sent out after registration.
+ * Instances of `%LINK%` will be replaced with the verification link.
+ * @example "/path/to/templates/email-verification.txt" // Value
+ * @example "Verify your account here: %LINK%" // File contents
+ */
+ EMAIL_VERIFICATION_TEXT_TEMPLATE?: string;
+ /**
+ * Path to a file containing the template for the HTML version of
+ * the email/account verification message sent out after registration.
+ * Instances of `%LINK%` will be replaced with the verification link.
+ * @example "/path/to/templates/email-verification.html" // Value
+ * @example 'Verify your account' // File contents
+ */
+ EMAIL_VERIFICATION_HTML_TEMPLATE?: string;
+ /**
+ * Same as `EMAIL_VERIFICATION_TEXT_TEMPLATE` but for the passwordless
+ * login email.
+ */
+ PASSWORDLESS_LOGIN_TEXT_TEMPLATE?: string;
+ /**
+ * Same as `EMAIL_VERIFICATION_HTML_TEMPLATE` but for the passwordless
+ * login email.
+ */
+ PASSWORDLESS_LOGIN_HTML_TEMPLATE?: string;
}
export interface Web extends Accownt.Env.Common {