Send new login location notification mail
This commit is contained in:
@@ -6,6 +6,7 @@ exports = module.exports = {
|
||||
appUpdatesAvailable,
|
||||
|
||||
sendInvite,
|
||||
sendNewLoginLocation,
|
||||
|
||||
backupFailed,
|
||||
|
||||
@@ -141,6 +142,37 @@ function sendInvite(user, invitor, inviteLink) {
|
||||
});
|
||||
}
|
||||
|
||||
function sendNewLoginLocation(user, newLocation) {
|
||||
assert.strictEqual(typeof user, 'object');
|
||||
assert.strictEqual(typeof newLocation, 'string');
|
||||
|
||||
debug('Sending new login location mail');
|
||||
|
||||
getMailConfig(function (error, mailConfig) {
|
||||
if (error) return debug('Error getting mail details:', error);
|
||||
|
||||
translation.getTranslations(function (error, translationAssets) {
|
||||
if (error) return debug('Error getting translations:', error);
|
||||
|
||||
var templateData = {
|
||||
user: user.displayName || user.username || user.email,
|
||||
cloudronName: mailConfig.cloudronName,
|
||||
cloudronAvatarUrl: settings.adminOrigin() + '/api/v1/cloudron/avatar'
|
||||
};
|
||||
|
||||
var mailOptions = {
|
||||
from: mailConfig.notificationFrom,
|
||||
to: user.fallbackEmail,
|
||||
subject: `[${mailConfig.cloudronName}] Login from new location detected`,
|
||||
text: render('new_login_location-text.ejs', templateData, translationAssets),
|
||||
html: render('new_login_location-html.ejs', templateData, translationAssets)
|
||||
};
|
||||
|
||||
sendMail(mailOptions);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function passwordReset(user) {
|
||||
assert.strictEqual(typeof user, 'object');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user