mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
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:
parent
7f4934d619
commit
0703c6d21d
3 changed files with 15 additions and 6 deletions
|
@ -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}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue