Merge pull request #7142 from overleaf/ii-6756-gmail-flags-emails-as-dangerous

Change security email title

GitOrigin-RevId: d33c9d7998ada059dac61ba0d13eefedd66237fc
This commit is contained in:
Timothée Alby 2022-03-23 10:20:22 +01:00 committed by Copybot
parent 7f4934d619
commit 0703c6d21d
3 changed files with 15 additions and 6 deletions

View file

@ -1,16 +1,25 @@
function _getIndefiniteArticle(providerName) { function _getIndefiniteArticle(providerName) {
const vowels = ['a', 'e', 'i', 'o', 'u'] const vowels = ['a', 'e', 'i', 'o', 'u']
if (vowels.includes(providerName.charAt(0).toLowerCase())) return 'an'
return 'a' return vowels.includes(providerName.charAt(0).toLowerCase()) ? 'an' : 'a'
}
function _actionBuilder(providerName, action, accountLinked) {
if (providerName.toLowerCase() !== 'google') {
return `${providerName} account ${action}`
}
return accountLinked ? `New account ${action}` : `Account ${action}`
} }
function linkOrUnlink(accountLinked, providerName, email) { function linkOrUnlink(accountLinked, providerName, email) {
const action = accountLinked ? 'linked' : 'no longer linked' const action = accountLinked ? 'linked' : 'no longer linked'
const actionDescribed = accountLinked ? 'was linked to' : 'was unlinked from' const actionDescribed = accountLinked ? 'was linked to' : 'was unlinked from'
const indefiniteArticle = _getIndefiniteArticle(providerName) const indefiniteArticle = _getIndefiniteArticle(providerName)
return { return {
to: email, to: email,
action: `${providerName} account ${action}`, action: _actionBuilder(providerName, action, accountLinked),
actionDescribed: `${indefiniteArticle} ${providerName} account ${actionDescribed} your account ${email}`, actionDescribed: `${indefiniteArticle} ${providerName} account ${actionDescribed} your account ${email}`,
} }
} }

View file

@ -201,7 +201,7 @@ function _sendSecurityAlert(accountLinked, providerId, user, userId) {
if (error) { if (error) {
logger.error( logger.error(
{ err: error, userId }, { err: error, userId },
`could not send security alert email when ${emailOptions.action}` `could not send security alert email when ${emailOptions.action.toLowerCase()}`
) )
} }
}) })

View file

@ -155,7 +155,7 @@ describe('ThirdPartyIdentityManager', function () {
err: anError, err: anError,
userId: this.userId, userId: this.userId,
}, },
'could not send security alert email when Google account linked' 'could not send security alert email when new account linked'
) )
done() done()
} }
@ -226,7 +226,7 @@ describe('ThirdPartyIdentityManager', function () {
err: anError, err: anError,
userId: this.userId, userId: this.userId,
}, },
'could not send security alert email when Google account no longer linked' 'could not send security alert email when account no longer linked'
) )
done() done()
} }