add otp page, mailer.js
This commit is contained in:
1 parent
515dd5a62c
commit
9fbc958d87
6 files changed
+185
-16
No files matched your search
@@ -1,11 +1,35 @@
|
|||||||
import nodemailer from "nodemailer";
|
import nodemailer from "nodemailer";
|
||||||
|
|
||||||
|
// Create a transporter using SMTP
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: "smtp.example.com",
|
host: "us1.smtp.bird.com",
|
||||||
port: 587,
|
port: 587,
|
||||||
secure: false, // use STARTTLS (upgrade connection to TLS after connecting)
|
secure: false, // use STARTTLS (upgrade connection to TLS after connecting)
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.SMTP_USER,
|
user: "bird",
|
||||||
pass: process.env.SMTP_PASS,
|
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);
|
||||||
|
}
|
||||||
Generated
+60
-12
@@ -9,6 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@messagebird/sdk": "^0.134.0",
|
||||||
"ejs": "^6.0.1",
|
"ejs": "^6.0.1",
|
||||||
"express": "^5.2.1",
|
"express": "^5.2.1",
|
||||||
"nodemailer": "^10.0.10",
|
"nodemailer": "^10.0.10",
|
||||||
@@ -35,6 +36,21 @@
|
|||||||
"kuler": "^2.0.0"
|
"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": {
|
"node_modules/@so-ric/colorspace": {
|
||||||
"version": "1.1.6",
|
"version": "1.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz",
|
||||||
@@ -45,6 +61,12 @@
|
|||||||
"text-hex": "1.0.x"
|
"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": {
|
"node_modules/@types/triple-beam": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
|
||||||
@@ -71,18 +93,18 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/body-parser": {
|
"node_modules/body-parser": {
|
||||||
"version": "2.3.0",
|
"version": "2.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
|
||||||
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
|
"integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bytes": "^3.1.2",
|
"bytes": "^3.1.2",
|
||||||
"content-type": "^2.0.0",
|
"content-type": "^2.1.0",
|
||||||
"debug": "^4.4.3",
|
"debug": "^4.4.3",
|
||||||
"http-errors": "^2.0.1",
|
"http-errors": "^2.0.1",
|
||||||
"iconv-lite": "^0.7.2",
|
"iconv-lite": "^0.7.3",
|
||||||
"on-finished": "^2.4.1",
|
"on-finished": "^2.4.1",
|
||||||
"qs": "^6.15.2",
|
"qs": "^6.16.1",
|
||||||
"raw-body": "^3.0.2",
|
"raw-body": "^3.0.2",
|
||||||
"type-is": "^2.1.0"
|
"type-is": "^2.1.0"
|
||||||
},
|
},
|
||||||
@@ -392,6 +414,12 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"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": {
|
"node_modules/fecha": {
|
||||||
"version": "4.2.3",
|
"version": "4.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
|
||||||
@@ -721,9 +749,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "10.0.10",
|
"version": "10.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.5.0.tgz",
|
||||||
"integrity": "sha512-He9XskOFms62SyAKkLu8CcGcYHAo+BSHSsORI8s4PJH8qZgZY4L4lDfvyN0twvmbpyG+eGrxpyBlskj9d9rJ8A==",
|
"integrity": "sha512-L/w/HH5MqpzMDuZD7fQdt/+KqymuvrpaApaIjAH2XA3ILePwlcvXCVVvP75xVrXCEt2ggK2marrrHHFB5Qu0kA==",
|
||||||
"license": "MIT-0",
|
"license": "MIT-0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
@@ -808,9 +836,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.16.0",
|
"version": "6.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
|
||||||
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
|
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-define-property": "^1.0.1",
|
"es-define-property": "^1.0.1",
|
||||||
@@ -1048,6 +1076,16 @@
|
|||||||
"node": "*"
|
"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": {
|
"node_modules/statuses": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
||||||
@@ -1121,6 +1159,16 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"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": {
|
"node_modules/unpipe": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@messagebird/sdk": "^0.134.0",
|
||||||
"ejs": "^6.0.1",
|
"ejs": "^6.0.1",
|
||||||
"express": "^5.2.1",
|
"express": "^5.2.1",
|
||||||
"nodemailer": "^10.0.10",
|
"nodemailer": "^10.0.10",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -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
@@ -106,6 +106,8 @@
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
|
|
||||||
.min-height-screen {
|
.min-height-screen {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
@@ -161,6 +163,44 @@
|
|||||||
|
|
||||||
<script>
|
<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() {
|
async function transition_sign_up() {
|
||||||
document.getElementById('form').classList.add('registering');
|
document.getElementById('form').classList.add('registering');
|
||||||
document.getElementById('login-btn').classList.add('btnfade');
|
document.getElementById('login-btn').classList.add('btnfade');
|
||||||
@@ -198,6 +238,7 @@
|
|||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
form.innerHTML = html;
|
form.innerHTML = html;
|
||||||
|
listen_for_otp();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
document.getElementById('notif').remove();
|
document.getElementById('notif').remove();
|
||||||
|
|||||||
Reference in new issue
Block a user