mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
fix: report email as not sent to fe if it throws (#844)
This commit is contained in:
parent
c9f67cc209
commit
52d3e9eb77
@ -33,12 +33,12 @@ export default class UserAdminController extends Controller {
|
||||
resetTokenService,
|
||||
sessionService,
|
||||
}: Pick<
|
||||
IUnleashServices,
|
||||
| 'userService'
|
||||
| 'accessService'
|
||||
| 'emailService'
|
||||
| 'resetTokenService'
|
||||
| 'sessionService'
|
||||
IUnleashServices,
|
||||
| 'userService'
|
||||
| 'accessService'
|
||||
| 'emailService'
|
||||
| 'resetTokenService'
|
||||
| 'sessionService'
|
||||
>,
|
||||
) {
|
||||
super(config);
|
||||
@ -137,13 +137,22 @@ export default class UserAdminController extends Controller {
|
||||
user.email,
|
||||
);
|
||||
|
||||
let emailSent = false;
|
||||
const emailConfigured = this.emailService.configured();
|
||||
if (emailConfigured) {
|
||||
await this.emailService.sendGettingStartedMail(
|
||||
createdUser.name,
|
||||
createdUser.email,
|
||||
inviteLink.toString(),
|
||||
);
|
||||
try {
|
||||
await this.emailService.sendGettingStartedMail(
|
||||
createdUser.name,
|
||||
createdUser.email,
|
||||
inviteLink.toString(),
|
||||
);
|
||||
emailSent = true;
|
||||
} catch (e) {
|
||||
this.logger.warn(
|
||||
'email was configured, but sending failed due to: ',
|
||||
e,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.logger.warn(
|
||||
'email was not sent to the user because email configuration is lacking',
|
||||
@ -153,7 +162,7 @@ export default class UserAdminController extends Controller {
|
||||
res.status(201).send({
|
||||
...createdUser,
|
||||
inviteLink,
|
||||
emailSent: emailConfigured,
|
||||
emailSent,
|
||||
rootRole,
|
||||
});
|
||||
} catch (e) {
|
||||
|
Loading…
Reference in New Issue
Block a user