add otp page, mailer.js

This commit is contained in:
niederwerfee committed 2026-11-10 22:41:18 -06:00
1 parent 515dd5a62c
commit 9fbc958d87
6 files changed
+185 -16

No files matched your search

+27 -3
View File
@@ -1,11 +1,35 @@
import nodemailer from "nodemailer";
// Create a transporter using SMTP
const transporter = nodemailer.createTransport({
host: "smtp.example.com",
host: "us1.smtp.bird.com",
port: 587,
secure: false, // use STARTTLS (upgrade connection to TLS after connecting)
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
user: "bird",
pass: "", // TODO: use environment variables
},
});
try {
await transporter.verify();
console.log("Server is ready to take our messages");
} catch (err) {
console.error("Verification failed:", err);
}
try {
const info = await transporter.sendMail({
from: '"CPC Security" <[email protected]>', // sender address
to: "[email protected]", // list of recipients
subject: "Hello", // subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // HTML body
});
console.log("Message sent: %s", info.messageId);
// Preview URL is only available when using an Ethereal test account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
} catch (err) {
console.error("Error while sending mail:", err);
}
+60 -12
View File
@@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@messagebird/sdk": "^0.134.0",
"ejs": "^6.0.1",
"express": "^5.2.1",
"nodemailer": "^10.0.10",
@@ -35,6 +36,21 @@
"kuler": "^2.0.0"
}
},
"node_modules/@messagebird/sdk": {
"version": "0.134.0",
"resolved": "https://registry.npmjs.org/@messagebird/sdk/-/sdk-0.134.0.tgz",
"integrity": "sha512-9QG1zJDe6DLFo51D5uWMUpEitzOiDyAGqD/DHbghqdrh5EKkd6ySF6v/4mG7TqAQN5B+14DG27NSv2JjAXXG9A==",
"license": "MIT",
"dependencies": {
"standardwebhooks": "1.0.0"
},
"engines": {
"node": ">=20.3.0"
},
"optionalDependencies": {
"undici": "6.29.1"
}
},
"node_modules/@so-ric/colorspace": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz",
@@ -45,6 +61,12 @@
"text-hex": "1.0.x"
}
},
"node_modules/@stablelib/base64": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz",
"integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==",
"license": "MIT"
},
"node_modules/@types/triple-beam": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
@@ -71,18 +93,18 @@
"license": "MIT"
},
"node_modules/body-parser": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
"integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
"content-type": "^2.0.0",
"content-type": "^2.1.0",
"debug": "^4.4.3",
"http-errors": "^2.0.1",
"iconv-lite": "^0.7.2",
"iconv-lite": "^0.7.3",
"on-finished": "^2.4.1",
"qs": "^6.15.2",
"qs": "^6.16.1",
"raw-body": "^3.0.2",
"type-is": "^2.1.0"
},
@@ -392,6 +414,12 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/fast-sha256": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz",
"integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==",
"license": "Unlicense"
},
"node_modules/fecha": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
@@ -721,9 +749,9 @@
}
},
"node_modules/nodemailer": {
"version": "10.0.10",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.10.tgz",
"integrity": "sha512-He9XskOFms62SyAKkLu8CcGcYHAo+BSHSsORI8s4PJH8qZgZY4L4lDfvyN0twvmbpyG+eGrxpyBlskj9d9rJ8A==",
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.5.0.tgz",
"integrity": "sha512-L/w/HH5MqpzMDuZD7fQdt/+KqymuvrpaApaIjAH2XA3ILePwlcvXCVVvP75xVrXCEt2ggK2marrrHHFB5Qu0kA==",
"license": "MIT-0",
"engines": {
"node": ">=20.0.0"
@@ -808,9 +836,9 @@
}
},
"node_modules/qs": {
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
"version": "6.17.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
@@ -1048,6 +1076,16 @@
"node": "*"
}
},
"node_modules/standardwebhooks": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.0.0.tgz",
"integrity": "sha512-BbHGOQK9olHPMvQNHWul6MYlrRTAOKn03rOe4A8O3CLWhNf4YHBqq2HJKKC+sfqpxiBY52pNeesD6jIiLDz8jg==",
"license": "MIT",
"dependencies": {
"@stablelib/base64": "^1.0.0",
"fast-sha256": "^1.3.0"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
@@ -1121,6 +1159,16 @@
"url": "https://opencollective.com/express"
}
},
"node_modules/undici": {
"version": "6.29.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz",
"integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=18.17"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+1
View File
@@ -10,6 +10,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@messagebird/sdk": "^0.134.0",
"ejs": "^6.0.1",
"express": "^5.2.1",
"nodemailer": "^10.0.10",
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

+56 -1
View File
@@ -1 +1,56 @@
<h1>Hello World!</h1>
<div class="otp-page">
<div class="otp-content">
<div class="is-flex is-flex-direction-column is-align-items-center">
<img src="../assets/sop/lock.png" class="image is-128x128">
<h1 class="title is-5">OTP Code Verification</h1>
<p class="subtitle is-6 mt-1">Code expires in 5 minutes</p>
</div>
<div class="is-flex is-justify-content-center is-align-items-center mt-3">
<a class="ml-5 mr-5">Resend Email</a>
<a class="ml-5 mr-5">Change Email</a>
</div>
<div class="is-flex is-justify-content-center is-align-items-center p-5">
<div class="inputs" id="inputs">
<input class="input is-rounded otp-input ml-2 mr-2" type="text" maxlength="1" inputmode="numeric">
<input class="input is-rounded otp-input ml-2 mr-2" type="text" maxlength="1" inputmode="numeric">
<input class="input is-rounded otp-input ml-2 mr-2" type="text" maxlength="1" inputmode="numeric">
<input class="input is-rounded otp-input ml-2 mr-2" type="text" maxlength="1" inputmode="numeric">
<input class="input is-rounded otp-input ml-2 mr-2" type="text" maxlength="1" inputmode="numeric">
<input class="input is-rounded otp-input ml-2 mr-2" type="text" maxlength="1" inputmode="numeric">
</div>
</div>
</div>
</div>
<style>
.box {
min-width: 500px !important;
position: relative !important;
left: 50% !important;
transform: translateX(-50%) !important;
}
.input {
max-width: 50px !important;
}
.otp-page {
position: fixed;
inset: 0;
display: grid;
place-items: center;
}
.input {
align-text: center;
}
.otp-content {
width: 100%;
}
</style>
+41
View File
@@ -106,6 +106,8 @@
</body>
<style>
.min-height-screen {
min-height: 100vh;
}
@@ -161,6 +163,44 @@
<script>
async function listen_for_otp() {
const inputs = document.getElementById("inputs");
inputs.addEventListener("input", function (e) {
const target = e.target;
const val = target.value;
if (isNaN(val)) {
target.value = "";
return;
}
if (val != "") {
const next = target.nextElementSibling;
if (next) {
next.focus();
}
}
});
inputs.addEventListener("keyup", function (e) {
const target = e.target;
const key = e.key.toLowerCase();
if (key == "backspace" || key == "delete") {
target.value = "";
const prev = target.previousElementSibling;
if (prev) {
prev.focus();
}
return;
}
});
}
async function transition_sign_up() {
document.getElementById('form').classList.add('registering');
document.getElementById('login-btn').classList.add('btnfade');
@@ -198,6 +238,7 @@
if (response.ok) {
form.innerHTML = html;
listen_for_otp();
} else {
try {
document.getElementById('notif').remove();