Skip to content

Commit cb7dd2e

Browse files
committed
do not start email if argvs not passed
1 parent ccb50d9 commit cb7dd2e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/create-app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function createApp (argv = {}) {
4444
// Setting options as local variable
4545
app.locals.ldp = ldp
4646

47-
if (argv.email) {
47+
if (argv.email && argv.email.host) {
4848
app.locals.email = new EmailService(argv.email)
4949
}
5050

lib/email-service.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class EmailService {
1818
}
1919
}
2020
sendMail (email, callback) {
21-
console.log(this.mailer)
2221
this.mailer.sendMail(email, callback)
2322
}
2423
}

lib/identity-provider.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,21 +534,22 @@ IdentityProvider.prototype.post = function (req, res, next) {
534534
self.create(options, cert, callback)
535535
},
536536
function (callback) {
537-
if (email) {
538-
email.sendEmail({
537+
if (email && options.email) {
538+
email.sendMail({
539539
from: `"no-reply" <${email.sender}>`, // sender address
540540
to: options.email,
541541
subject: 'Account created',
542542
text: 'Your account has been created',
543543
html: '<b>Your account has been created</b>'
544-
}, callback)
544+
}, (err) => {
545+
debug('Error sending email', err)
546+
callback()
547+
})
545548
} else {
546549
callback()
547550
}
548551
}
549552
], function (err) {
550-
// TODO at the moment this will collect the email error
551-
// maybe we don't need to do so
552553
if (err) {
553554
err.status = err.status || 500
554555
debug('Error creating ' + options.user + ': ' + err.message)

0 commit comments

Comments
 (0)