move the database and mailer to own log sub dir, add all email change logic

This commit is contained in:
creations 2025-06-13 20:33:29 -04:00
parent ddd00e3f85
commit a783a0e663
Signed by: creations
GPG key ID: 8F553AA4320FC711
26 changed files with 808 additions and 225 deletions

View file

@ -31,3 +31,4 @@ export * from "./server";
export * from "./validation";
export * from "./database";
export * from "./mailer";
export * from "./user";

View file

@ -0,0 +1 @@
export * from "./update";

View file

@ -0,0 +1,6 @@
const emailUpdateTimes = {
coolDownMinutes: 5,
tokenExpiryHours: 3,
};
export { emailUpdateTimes };

View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{subject}}</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
line-height: 1.5;
}
a {
color: #0066cc;
}
</style>
</head>
<body>
<h1>Email Address Changed - {{companyName}}</h1>
<p>Hi {{displayName}},</p>
<p><strong>Your email address has been successfully changed.</strong></p>
<p><strong>Change Details:</strong></p>
<p>Previous Email: {{oldEmail}} (this address)<br>
New Email: {{newEmail}}<br>
Changed On: {{changeTime}}</p>
<p><strong>Important:</strong> You will no longer receive account emails at this address ({{oldEmail}}). All future communications will be sent to {{newEmail}}.</p>
<p><strong>For future logins, please use:</strong></p>
<p>Email: {{newEmail}}<br>
Password: (unchanged)</p>
<p><strong>If this change was not authorized by you:</strong> Contact our support team immediately at {{supportEmail}}. Your account may have been compromised and we will help you recover it.</p>
<hr>
<p><small>User ID: {{id}} | {{companyName}}</small></p>
</body>
</html>

View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{subject}}</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
line-height: 1.5;
}
a {
color: #0066cc;
}
</style>
</head>
<body>
<h1>Email Change Request - {{companyName}}</h1>
<p>Hi {{displayName}},</p>
<p><strong>Security Notice:</strong> Someone requested to change your account email address.</p>
<p><strong>Change Details:</strong></p>
<p>Current Email: {{currentEmail}}<br>
Requested New Email: {{newEmail}}<br>
Request Time: {{requestTime}}</p>
<p>A verification email has been sent to <strong>{{newEmail}}</strong>.</p>
<p>{{willExpire}} if not completed.</p>
<p><strong>If this was you:</strong> Check your new email ({{newEmail}}) and click the verification link to complete the change.</p>
<p><strong>If this was NOT you:</strong> Your account may be compromised. Please change your password immediately and contact our support team at {{supportEmail}}.</p>
<p>Questions? Contact {{supportEmail}}</p>
<hr>
<p><small>User ID: {{id}} | {{companyName}}</small></p>
</body>
</html>

View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{subject}}</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
line-height: 1.5;
}
.verify-button {
display: inline-block;
background-color: #0066cc;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 3px;
margin: 15px 0;
}
</style>
</head>
<body>
<h1>Email Change Verification - {{companyName}}</h1>
<p>Hi {{displayName}},</p>
<p>You requested to change your email address from <strong>{{currentEmail}}</strong> to <strong>{{newEmail}}</strong>.</p>
<p>To complete this email change, please click the button below:</p>
<a href="{{verificationUrl}}" class="verify-button">Verify Email Change</a>
<p>{{willExpire}} for security reasons.</p>
<p><strong>Important:</strong> After verification, your account email will be changed to this address and you'll need to use it for future logins.</p>
<p>If you did not request this email change, contact {{supportEmail}} immediately.</p>
<p>Questions? Contact {{supportEmail}}</p>
<hr>
<p><small>User ID: {{id}} | {{companyName}}</small></p>
</body>
</html>

View file

@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -13,35 +12,28 @@
padding: 20px;
line-height: 1.5;
}
a {
color: #0066cc;
.reset-button {
display: inline-block;
background-color: #0066cc;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 3px;
margin: 15px 0;
}
</style>
</head>
<body>
<h1>Password Reset - {{companyName}}</h1>
<p>Hi {{displayName}},</p>
<p>You requested a password reset for your account. Click the button below to reset your password:</p>
<p>You requested a password reset for your account. Click the link below to reset your password:</p>
<p><a href="{{resetUrl}}">{{resetUrl}}</a></p>
<a href="{{resetUrl}}" class="reset-button">Reset Password</a>
<p>{{willExpire}} for security reasons.</p>
<p>If you did not request this password reset, please ignore this email. Your password will remain unchanged.</p>
<p>If you did not request this password reset, please contact {{supportEmail}} immediately. Your password will remain unchanged.</p>
<p>Questions? Contact {{supportEmail}}</p>
<p>Best regards,<br>
The {{companyName}} team</p>
<hr>
<p><small>User ID: {{id}} | © {{currentYear}} {{companyName}}</small></p>
<p><small>User ID: {{id}} | {{companyName}}</small></p>
</body>
</html>
</html>

View file

@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -13,33 +12,29 @@
padding: 20px;
line-height: 1.5;
}
a {
color: #0066cc;
.verify-button {
display: inline-block;
background-color: #0066cc;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 3px;
margin: 15px 0;
}
</style>
</head>
<body>
<h1>Welcome to {{companyName}}!</h1>
<p>Hi {{displayName}},</p>
<p>Please verify your email address:</p>
<p><a href="{{verificationUrl}}">{{verificationUrl}}</a></p>
<a href="{{verificationUrl}}" class="verify-button">Verify Email</a>
<p>{{willExpire}} for security reasons.</p>
<p>Questions? Contact {{supportEmail}}</p>
<p>Best regards,<br>
The {{companyName}} team</p>
<hr>
<p><small>User ID: {{id}} | © {{currentYear}} {{companyName}}</small></p>
<p><small>User ID: {{id}} | {{companyName}}</small></p>
</body>
</html>
</html>