• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #12296

pending completion
#12296

push

circleci

web-flow
Merge pull request #2830 from mozilla/MNTOR-1160/add-new-email

Mntor 1160/add new email

282 of 1332 branches covered (21.17%)

Branch coverage included in aggregate %.

79 of 79 new or added lines in 7 files covered. (100.0%)

959 of 3548 relevant lines covered (27.03%)

2.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/client/js/partials/settings.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
const settingsAlertOptionsInputs = document.getElementsByClassName('js-settings-alert-options-input')
×
6

7
if (settingsAlertOptionsInputs?.length) {
×
8
  for (const inputElement of settingsAlertOptionsInputs) {
×
9
    inputElement.addEventListener('change', async event => {
×
10
      try {
×
11
        const communicationOption = event.target.getAttribute('data-alert-option')
×
12
        const csrfToken = document
×
13
          .querySelector('.js-settings[data-csrf-token]')
14
          .getAttribute('data-csrf-token')
15

16
        const response = await fetch('/api/v1/user/update-comm-option', {
×
17
          headers: {
18
            'Content-Type': 'application/json',
19
            'x-csrf-token': csrfToken
20
          },
21
          mode: 'same-origin',
22
          method: 'POST',
23
          body: JSON.stringify({ communicationOption })
24
        })
25

26
        if (response && response.redirected === true) {
×
27
          throw response.error
×
28
        }
29
      } catch (err) {
30
        throw new Error(`Updating communication option failed: ${err}`)
×
31
      }
32
      event.preventDefault()
×
33
      return false
×
34
    })
35
  }
36
}
37

38
const settingsRemoveEmailButtons = document.getElementsByClassName('js-remove-email-button')
×
39
if (settingsRemoveEmailButtons?.length) {
×
40
  for (const removeEmailButton of settingsRemoveEmailButtons) {
×
41
    removeEmailButton.addEventListener('click', async event => {
×
42
      try {
×
43
        const subscriberId = event.target.getAttribute('data-subscriber-id')
×
44
        const emailId = event.target.getAttribute('data-email-id')
×
45
        const csrfToken = document
×
46
          .querySelector('.js-settings[data-csrf-token]')
47
          .getAttribute('data-csrf-token')
48

49
        const response = await fetch('/api/v1/user/remove-email', {
×
50
          headers: {
51
            'Content-Type': 'application/json',
52
            'x-csrf-token': csrfToken
53
          },
54
          mode: 'same-origin',
55
          method: 'POST',
56
          body: JSON.stringify({ emailId, subscriberId })
57
        })
58

59
        if (response && response.redirected === true) {
×
60
          return window.location.reload(true)
×
61
        }
62
      } catch (err) {
63
        console.error(`Error: ${err}`)
×
64
      }
65
    })
66
  }
67
}
68

69
const settingsResendEmailLinks = document.getElementsByClassName('js-settings-resend-email')
×
70
if (settingsResendEmailLinks?.length) {
×
71
  for (const resendEmailLink of settingsResendEmailLinks) {
×
72
    resendEmailLink.addEventListener('click', async event => {
×
73
      try {
×
74
        const emailId = event.target.getAttribute('data-email-id')
×
75
        const csrfToken = document
×
76
          .querySelector('.js-settings[data-csrf-token]')
77
          .getAttribute('data-csrf-token')
78

79
        const response = await fetch('/api/v1/user/resend-email', {
×
80
          headers: {
81
            'Content-Type': 'application/json',
82
            'x-csrf-token': csrfToken
83
          },
84
          mode: 'same-origin',
85
          method: 'POST',
86
          body: JSON.stringify({ emailId })
87
        })
88

89
        if (response?.redirected) {
×
90
          throw response.error
×
91
        }
92
      } catch (err) {
93
        throw new Error(`Re-sending verification email failed: ${err}`)
×
94
      }
95
      event.preventDefault()
×
96
      return false
×
97
    })
98
  }
99
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc