Merge pull request #2535 from bluewave-labs/fix/invite-email
fix: verify transport before sending email
This commit is contained in:
4 files changed
+23
-7
No files matched your search
@@ -168,7 +168,7 @@ const TeamPanel = () => {
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createToast({
|
createToast({
|
||||||
body: error.message || "Unknown error.",
|
body: error?.response?.data?.msg || error.message || "Unknown error.",
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsSendingInvite(false);
|
setIsSendingInvite(false);
|
||||||
@@ -268,7 +268,7 @@ const TeamPanel = () => {
|
|||||||
value={toInvite.email}
|
value={toInvite.email}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
error={errors.email ? true : false}
|
error={errors.email ? true : false}
|
||||||
helperText={errors.email}
|
helperText={t(errors.email)}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
id="team-member-role"
|
id="team-member-role"
|
||||||
|
|||||||
@@ -77,11 +77,16 @@ class InviteController {
|
|||||||
name: firstname,
|
name: firstname,
|
||||||
link: `${clientHost}/register/${inviteToken.token}`,
|
link: `${clientHost}/register/${inviteToken.token}`,
|
||||||
});
|
});
|
||||||
await this.emailService.sendEmail(
|
const result = await this.emailService.sendEmail(
|
||||||
req.body.email,
|
req.body.email,
|
||||||
"Welcome to Uptime Monitor",
|
"Welcome to Uptime Monitor",
|
||||||
html
|
html
|
||||||
);
|
);
|
||||||
|
if (!result) {
|
||||||
|
return res.error({
|
||||||
|
msg: "Failed to send invite e-mail... Please verify your settings.",
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn({
|
logger.warn({
|
||||||
message: error.message,
|
message: error.message,
|
||||||
|
|||||||
@@ -137,6 +137,17 @@ class EmailService {
|
|||||||
};
|
};
|
||||||
this.transporter = this.nodemailer.createTransport(emailConfig);
|
this.transporter = this.nodemailer.createTransport(emailConfig);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.transporter.verify();
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.warn({
|
||||||
|
message: "Email transporter verification failed",
|
||||||
|
service: SERVICE_NAME,
|
||||||
|
method: "verifyTransporter",
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const info = await this.transporter.sendMail({
|
const info = await this.transporter.sendMail({
|
||||||
to: to,
|
to: to,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Logger {
|
|||||||
info(config) {
|
info(config) {
|
||||||
const logEntry = this.buildLogEntry("info", config);
|
const logEntry = this.buildLogEntry("info", config);
|
||||||
this.cacheLog(logEntry);
|
this.cacheLog(logEntry);
|
||||||
this.logger.info(config.message, logEntry);
|
this.logger.info(logEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +90,7 @@ class Logger {
|
|||||||
warn(config) {
|
warn(config) {
|
||||||
const logEntry = this.buildLogEntry("warn", config);
|
const logEntry = this.buildLogEntry("warn", config);
|
||||||
this.cacheLog(logEntry);
|
this.cacheLog(logEntry);
|
||||||
this.logger.warn(config.message, logEntry);
|
this.logger.warn(logEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +104,7 @@ class Logger {
|
|||||||
error(config) {
|
error(config) {
|
||||||
const logEntry = this.buildLogEntry("error", config);
|
const logEntry = this.buildLogEntry("error", config);
|
||||||
this.cacheLog(logEntry);
|
this.cacheLog(logEntry);
|
||||||
this.logger.error(config.message, logEntry);
|
this.logger.error(logEntry);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Logs a debug message.
|
* Logs a debug message.
|
||||||
@@ -117,7 +117,7 @@ class Logger {
|
|||||||
debug(config) {
|
debug(config) {
|
||||||
const logEntry = this.buildLogEntry("debug", config);
|
const logEntry = this.buildLogEntry("debug", config);
|
||||||
this.cacheLog(logEntry);
|
this.cacheLog(logEntry);
|
||||||
this.logger.debug(config.message, logEntry);
|
this.logger.debug(logEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheLog(entry) {
|
cacheLog(entry) {
|
||||||
|
|||||||
Reference in new issue
Block a user