Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #245 from mozilla/i183
Browse files Browse the repository at this point in the history
fix(templates): remove suspicious_location template
  • Loading branch information
seanmonstar committed Jan 3, 2017
2 parents f430684 + 1d87721 commit dd8b653
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 226 deletions.
42 changes: 0 additions & 42 deletions mailer.js
Expand Up @@ -22,7 +22,6 @@ module.exports = function (log) {
'passwordResetEmail': 'password-reset-success',
'postVerifyEmail': 'account-verified',
'recoveryEmail': 'forgot-password',
'suspiciousLocationEmail': 'suspicious-location',
'unblockCode': 'new-unblock',
'verifyEmail': 'welcome',
'verifyLoginEmail': 'new-signin',
Expand All @@ -41,7 +40,6 @@ module.exports = function (log) {
'passwordResetRequiredEmail': 'password-reset',
'postVerifyEmail': 'connect-device',
'recoveryEmail': 'reset-password',
'suspiciousLocationEmail': 'password-reset',
'unblockCode': 'unblock-code',
'verificationReminderFirstEmail': 'activate',
'verificationReminderSecondEmail': 'activate',
Expand Down Expand Up @@ -613,46 +611,6 @@ module.exports = function (log) {
})
}

Mailer.prototype.suspiciousLocationEmail = function (message) {
log.trace({ op: 'mailer.suspiciousLocationEmail', email: message.email, uid: message.uid })

var templateName = 'suspiciousLocationEmail'
var links = this._generateLinks(this.initiatePasswordResetUrl, message.email, {}, templateName)

// the helper function `t` references `this.translator`. Because of
// the way Handlebars `each` loops work, a translator instance must be
// added to each entry or else no translator is available when translating
// the entry.
var translator = this.translator(message.acceptLanguage)

message.locations.forEach(function (entry) {
entry.translator = translator
})

var headers = {
'X-Link': links.resetLink
}

if (message.flowBeginTime && message.flowId) {
headers['X-Flow-Id'] = message.flowId
headers['X-Flow-Begin-Time'] = message.flowBeginTime
}

return this.send({
acceptLanguage: message.acceptLanguage,
email: message.email,
headers: headers,
subject: gettext('Suspicious activity with your Firefox Account'),
template: templateName,
templateValues: {
passwordManagerInfoUrl: links.passwordManagerInfoUrl,
privacyUrl: links.privacyUrl,
locations: message.locations,
resetLink: links.resetLink
}
})
}

Mailer.prototype.verificationReminderEmail = function (message) {
log.trace({ op: 'mailer.verificationReminderEmail', email: message.email, type: message.type })

Expand Down
1 change: 0 additions & 1 deletion scripts/write-to-disk.js
Expand Up @@ -16,7 +16,6 @@
* passwordResetRequiredEmail
* postVerifyEmail
* recoveryEmail
* suspiciousLocationEmail
* unblockCodeEmail
* verificationReminderEmail:first
* verificationReminderEmail:second
Expand Down
1 change: 0 additions & 1 deletion templates/index.js
Expand Up @@ -54,7 +54,6 @@ module.exports = function () {
'password_reset_required',
'post_verify',
'recovery',
'suspicious_location',
'unblock_code',
'verification_reminder_first',
'verification_reminder_second',
Expand Down
118 changes: 0 additions & 118 deletions templates/suspicious_location.html

This file was deleted.

21 changes: 0 additions & 21 deletions templates/suspicious_location.txt

This file was deleted.

45 changes: 2 additions & 43 deletions test/local/mailer_tests.js
Expand Up @@ -24,7 +24,6 @@ var messageTypes = [
'passwordResetRequiredEmail',
'postVerifyEmail',
'recoveryEmail',
'suspiciousLocationEmail',
'unblockCodeEmail',
'verificationReminderEmail',
'verifyEmail',
Expand All @@ -45,7 +44,6 @@ var typesContainPasswordResetLinks = [
'passwordChangedEmail',
'passwordResetEmail',
'passwordResetRequiredEmail',
'suspiciousLocationEmail'
]

var typesContainPasswordChangeLinks = [
Expand Down Expand Up @@ -80,7 +78,6 @@ var typesContainLocationData = [

var typesContainPasswordManagerInfoLinks = [
'passwordResetRequiredEmail',
'suspiciousLocationEmail'
]

function includes(haystack, needle) {
Expand Down Expand Up @@ -424,44 +421,6 @@ P.all(
mailer[type](message)
}
)
} else if (type === 'suspiciousLocationEmail') {
var locations = [
{
device: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:48.0) Gecko/20100101 Firefox/48.0',
location: 'Mountain View, CA',
timestamp: (new Date()).toString()
},
{
device: 'MSIE 10',
location: 'London, United Kingdom',
timestamp: (new Date()).toString()
}
]

message = {
email: 'a@b.com',
locations: locations
}

test(
'test suspicious location entries are added for ' + type,
function (t) {
mailer.mailer.sendMail = function (emailConfig) {
locations.forEach(function (location) {
t.ok(includes(emailConfig.html, location.device))
t.ok(includes(emailConfig.html, location.location))
t.ok(includes(emailConfig.html, location.timestamp))

t.ok(includes(emailConfig.text, location.device))
t.ok(includes(emailConfig.text, location.location))
t.ok(includes(emailConfig.text, location.timestamp))
})

t.end()
}
mailer[type](message)
}
)
} else if (type === 'verificationReminderEmail') {
var reminderMessage = extend(message, {
type: 'customType'
Expand Down Expand Up @@ -565,7 +524,7 @@ P.all(
var message = {
email: 'test@restmail.net',
subject: 'subject',
template: 'suspiciousLocationEmail',
template: 'verifyLoginEmail',
uid: 'foo'
}

Expand All @@ -588,7 +547,7 @@ P.all(
var message = {
email: 'test@restmail.net',
subject: 'subject',
template: 'suspiciousLocationEmail',
template: 'verifyLoginEmail',
uid: 'foo'
}

Expand Down

0 comments on commit dd8b653

Please sign in to comment.