Просмотр исходного кода

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

Change security email title

GitOrigin-RevId: d33c9d7998ada059dac61ba0d13eefedd66237fc
Timothée Alby 4 лет назад
Родитель
Сommit
0703c6d21d

+ 12 - 3
services/web/app/src/Features/Email/EmailOptionsHelper.js

@@ -1,16 +1,25 @@
 function _getIndefiniteArticle(providerName) {
   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) {
   const action = accountLinked ? 'linked' : 'no longer linked'
   const actionDescribed = accountLinked ? 'was linked to' : 'was unlinked from'
   const indefiniteArticle = _getIndefiniteArticle(providerName)
+
   return {
     to: email,
-    action: `${providerName} account ${action}`,
+    action: _actionBuilder(providerName, action, accountLinked),
     actionDescribed: `${indefiniteArticle} ${providerName} account ${actionDescribed} your account ${email}`,
   }
 }

+ 1 - 1
services/web/app/src/Features/User/ThirdPartyIdentityManager.js

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

+ 2 - 2
services/web/test/unit/src/User/ThirdPartyIdentityManagerTests.js

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