@loomcore/api 0.1.126 → 0.1.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/test-email-client.d.ts +1 -1
- package/dist/__tests__/test-email-client.js +2 -2
- package/dist/databases/postgres/migrations/postgres-initial-schema.js +1 -1
- package/dist/models/email-client.interface.d.ts +1 -1
- package/dist/services/auth.service.js +1 -2
- package/dist/services/email.service.d.ts +1 -2
- package/dist/services/email.service.js +5 -29
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IEmailClient } from "../models/email-client.interface.js";
|
|
2
2
|
export declare class TestEmailClient implements IEmailClient {
|
|
3
|
-
|
|
3
|
+
sendResetPasswordEmail(toEmailAddress: string, resetPasswordLink: string): Promise<void>;
|
|
4
4
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class TestEmailClient {
|
|
2
|
-
|
|
3
|
-
console.log(`Sending email to ${toEmailAddress} with
|
|
2
|
+
sendResetPasswordEmail(toEmailAddress, resetPasswordLink) {
|
|
3
|
+
console.log(`Sending reset password email to ${toEmailAddress} with reset password link ${resetPasswordLink}`);
|
|
4
4
|
return Promise.resolve();
|
|
5
5
|
}
|
|
6
6
|
}
|
|
@@ -55,7 +55,7 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
55
55
|
"middle_name" VARCHAR(255),
|
|
56
56
|
"last_name" VARCHAR(255) NOT NULL,
|
|
57
57
|
"date_of_birth" DATE,
|
|
58
|
-
"ssn"
|
|
58
|
+
"ssn" BIGINT,
|
|
59
59
|
"is_agent" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
60
60
|
"is_client" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
61
61
|
"is_employee" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
@@ -202,8 +202,7 @@ export class AuthService extends MultiTenantApiService {
|
|
|
202
202
|
const httpOrHttps = config.env === 'local' ? 'http' : 'https';
|
|
203
203
|
const urlEncodedEmail = encodeURIComponent(emailAddress);
|
|
204
204
|
const resetPasswordLink = `${httpOrHttps}://${config.app.name}/reset-password/${passwordResetToken.token}/${urlEncodedEmail}`;
|
|
205
|
-
|
|
206
|
-
await this.emailService.sendHtmlEmail(emailAddress, `Reset Password for ${config.app.name}`, htmlEmailBody);
|
|
205
|
+
await this.emailService.sendResetPasswordEmail(emailAddress, resetPasswordLink);
|
|
207
206
|
}
|
|
208
207
|
async resetPassword(email, passwordResetToken, password) {
|
|
209
208
|
const lowerCaseEmail = email.toLowerCase();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare class EmailService {
|
|
2
|
-
private emailConfig;
|
|
3
2
|
private emailClient;
|
|
4
3
|
constructor();
|
|
5
|
-
|
|
4
|
+
sendResetPasswordEmail(emailAddress: string, resetPasswordLink: string): Promise<void>;
|
|
6
5
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { ServerError } from '../errors/index.js';
|
|
2
2
|
import { config } from '../config/index.js';
|
|
3
3
|
export class EmailService {
|
|
4
|
-
emailConfig;
|
|
5
4
|
emailClient;
|
|
6
5
|
constructor() {
|
|
7
|
-
if (config.email) {
|
|
8
|
-
this.emailConfig = config.email;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
throw new ServerError('Email configuration is not available. Email API credentials are not set in the config.');
|
|
12
|
-
}
|
|
13
6
|
if (config.thirdPartyClients?.emailClient) {
|
|
14
7
|
this.emailClient = config.thirdPartyClients.emailClient;
|
|
15
8
|
}
|
|
@@ -17,31 +10,14 @@ export class EmailService {
|
|
|
17
10
|
throw new ServerError('Email client is not available. Email client is not set in the config.');
|
|
18
11
|
}
|
|
19
12
|
}
|
|
20
|
-
async
|
|
21
|
-
const messageData = {
|
|
22
|
-
Messages: [
|
|
23
|
-
{
|
|
24
|
-
From: {
|
|
25
|
-
Email: this.emailConfig.fromAddress,
|
|
26
|
-
Name: config.app.name
|
|
27
|
-
},
|
|
28
|
-
To: [
|
|
29
|
-
{
|
|
30
|
-
Email: emailAddress
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
Subject: subject,
|
|
34
|
-
HTMLPart: body
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
};
|
|
13
|
+
async sendResetPasswordEmail(emailAddress, resetPasswordLink) {
|
|
38
14
|
try {
|
|
39
|
-
await this.emailClient.
|
|
40
|
-
console.log(`
|
|
15
|
+
await this.emailClient.sendResetPasswordEmail(emailAddress, resetPasswordLink);
|
|
16
|
+
console.log(`Reset password email sent to ${emailAddress} with reset password link ${resetPasswordLink}`);
|
|
41
17
|
}
|
|
42
18
|
catch (error) {
|
|
43
|
-
console.error('Error sending email:', error);
|
|
44
|
-
throw new ServerError('Error sending email');
|
|
19
|
+
console.error('Error sending reset password email:', error);
|
|
20
|
+
throw new ServerError('Error sending reset password email');
|
|
45
21
|
}
|
|
46
22
|
}
|
|
47
23
|
}
|