mirror of
https://github.com/xfarrow/blink
synced 2025-04-16 17:07:48 +02:00
update email settings
This commit is contained in:
parent
ec68bf292d
commit
a06d15db47
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
# API server settings
|
# API server settings
|
||||||
API_SERVER_PORT = 3000
|
API_SERVER_PORT = 3000
|
||||||
|
|
||||||
JWT_SECRET_KEY = jwt-secret # Change this in production
|
JWT_SECRET_KEY = jwt-secret # Change this in production
|
||||||
|
|
||||||
LIMITER_WINDOW = 3600000 # Milliseconds in limiter window
|
LIMITER_WINDOW = 3600000 # Milliseconds in limiter window
|
||||||
LIMITER_MAXIMUM_PER_WINDOW = 5000 # Requests for each limiter window
|
LIMITER_MAXIMUM_PER_WINDOW = 5000 # Requests for each limiter window
|
||||||
|
|
||||||
SMTP_USERNAME = blink@ik.me # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
SMTP_USERNAME = blink@ik.me # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
||||||
SMTP_PASSWORD = your_password # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
SMTP_PASSWORD = your_password # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
||||||
SMTP_PORT = 465 # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
SMTP_PORT = 465 # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
||||||
|
SMTP_HOST = mail.infomaniak.com # Fill only if NEEDS_EMAIL_VERIFICATION is true
|
||||||
|
SMTP_SECURE = true
|
||||||
|
|
||||||
FRONT_END_URL = http://localhost # Primary fron-end's root URL
|
FRONT_END_URL = http://localhost # Primary fron-end's root URL
|
||||||
|
|
||||||
# Database settings
|
# Database settings
|
||||||
@ -18,4 +24,4 @@ POSTGRES_PORT = 5432
|
|||||||
|
|
||||||
# Application settings
|
# Application settings
|
||||||
ALLOW_USER_REGISTRATION = true
|
ALLOW_USER_REGISTRATION = true
|
||||||
NEEDS_EMAIL_VERIFICATION = false # Does this server need users to verify their e-mail address?
|
NEEDS_EMAIL_VERIFICATION = true # Does this server need users to verify their e-mail address?
|
@ -2,18 +2,33 @@ const nodemailer = require('nodemailer');
|
|||||||
|
|
||||||
// Create a transporter object using the default SMTP transport
|
// Create a transporter object using the default SMTP transport
|
||||||
let transporter = nodemailer.createTransport({
|
let transporter = nodemailer.createTransport({
|
||||||
service: 'Infomaniak',
|
host: process.env.SMTP_HOST,
|
||||||
|
port: process.env.SMTP_PORT,
|
||||||
|
secure: Boolean(process.env.SMTP_SECURE),
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.SMTP_USERNAME,
|
user: process.env.SMTP_USERNAME,
|
||||||
pass: process.env.SMTP_PASSWORD
|
pass: process.env.SMTP_PASSWORD
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the destination address and the activation code, sends an e-mail
|
||||||
|
* to activate such account.
|
||||||
|
* @param {*} destinationAddress
|
||||||
|
* @param {*} code
|
||||||
|
*/
|
||||||
function sendConfirmationLink(destinationAddress, code) {
|
function sendConfirmationLink(destinationAddress, code) {
|
||||||
const confirmationLink = `${process.env.FRONT_END_URL}/activate-account.html?q=${code}`
|
const confirmationLink = `${process.env.FRONT_END_URL}/activate-account.html?q=${code}`
|
||||||
sendMail(destinationAddress, 'Verify your Blink Account', null, getConfirmationLinkHtmlPage(confirmationLink));
|
sendMail(destinationAddress, 'Verify your Blink Account', null, getConfirmationLinkHtmlPage(confirmationLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} destinationAddress Destination Address
|
||||||
|
* @param {*} subject Subject
|
||||||
|
* @param {*} text Plain-text body
|
||||||
|
* @param {*} html Html body
|
||||||
|
*/
|
||||||
function sendMail(destinationAddress, subject, text, html) {
|
function sendMail(destinationAddress, subject, text, html) {
|
||||||
|
|
||||||
let mailOptions = {
|
let mailOptions = {
|
||||||
@ -31,6 +46,14 @@ function sendMail(destinationAddress, subject, text, html) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an Html page to be rendered in the user's email client which has an
|
||||||
|
* "Activate Account" button
|
||||||
|
* @param {*} confirmationLink the link the user shoud follow to activate the
|
||||||
|
* account
|
||||||
|
*
|
||||||
|
* @returns A string representing the Html page.
|
||||||
|
*/
|
||||||
function getConfirmationLinkHtmlPage(confirmationLink) {
|
function getConfirmationLinkHtmlPage(confirmationLink) {
|
||||||
return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Activation Page</title><style>body{font-family:Arial,sans-serif;background-color:#f4f4f4;margin:0;padding:0;display:flex;justify-content:center;align-items:center;height:100vh}.container{text-align:center;padding:20px;border-radius:10px;box-shadow:0 0 20px rgba(0,0,0,.1);background-color:#fff}h1{color:#333}a{display:block;padding:10px 20px;margin-top:20px;background-color:#007bff;color:#fff;text-decoration:none;border-radius:5px;transition:background-color .3s ease}a:hover{background-color:#0056b3}</style></head><body><div class="container"><h1>Activate your Blink Account</h1><p>Please click the button below to activate your account</p><a href="${confirmationLink}">Activate Now</a></div></body></html>`;
|
return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Activation Page</title><style>body{font-family:Arial,sans-serif;background-color:#f4f4f4;margin:0;padding:0;display:flex;justify-content:center;align-items:center;height:100vh}.container{text-align:center;padding:20px;border-radius:10px;box-shadow:0 0 20px rgba(0,0,0,.1);background-color:#fff}h1{color:#333}a{display:block;padding:10px 20px;margin-top:20px;background-color:#007bff;color:#fff;text-decoration:none;border-radius:5px;transition:background-color .3s ease}a:hover{background-color:#0056b3}</style></head><body><div class="container"><h1>Activate your Blink Account</h1><p>Please click the button below to activate your account</p><a href="${confirmationLink}">Activate Now</a></div></body></html>`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user