mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Added an unsubscribe url for recruit notifications.
This commit is contained in:
parent
c85971e5e6
commit
f7035d4220
2 changed files with 29 additions and 7 deletions
|
@ -132,14 +132,24 @@ module.exports.setup = (app) ->
|
|||
return errors.notFound res, "No user found with email '#{req.query.email}'"
|
||||
|
||||
emails = _.clone(user.get('emails')) or {}
|
||||
emailSettings.enabled = false for emailSettings in _.values(emails)
|
||||
emails.generalNews ?= {}
|
||||
emails.generalNews.enabled = false
|
||||
emails.anyNotes ?= {}
|
||||
emails.anyNotes.enabled = false
|
||||
user.update {$set: {emails: emails, emailSubscriptions: []}}, {}, =>
|
||||
msg = ''
|
||||
|
||||
if req.query.recruitNotes
|
||||
emails.recruitNotes ?= {}
|
||||
emails.recruitNotes.enabled = false
|
||||
msg = "Unsubscribed #{req.query.email} from recruiting emails."
|
||||
|
||||
else
|
||||
msg = "Unsubscribed #{req.query.email} from all CodeCombat emails. Sorry to see you go!"
|
||||
emailSettings.enabled = false for emailSettings in _.values(emails)
|
||||
emails.generalNews ?= {}
|
||||
emails.generalNews.enabled = false
|
||||
emails.anyNotes ?= {}
|
||||
emails.anyNotes.enabled = false
|
||||
|
||||
user.update {$set: {emails: emails}}, {}, =>
|
||||
return errors.serverError res, 'Database failure.' if err
|
||||
res.send "Unsubscribed #{req.query.email} from all CodeCombat emails. Sorry to see you go! <p><a href='/account/settings'>Account settings</a></p>"
|
||||
res.send msg + "<p><a href='/account/settings'>Account settings</a></p>"
|
||||
res.end()
|
||||
|
||||
module.exports.loginUser = loginUser = (req, res, user, send=true, next=null) ->
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require '../common'
|
||||
request = require 'request'
|
||||
User = require '../../../server/users/User'
|
||||
|
||||
urlLogin = getURL('/auth/login')
|
||||
urlReset = getURL('/auth/reset')
|
||||
|
@ -134,3 +135,14 @@ describe '/auth/reset', ->
|
|||
form = req.form()
|
||||
form.append('username', 'scott@gmail.com')
|
||||
form.append('password', 'nada')
|
||||
|
||||
describe '/auth/unsubscribe', ->
|
||||
|
||||
it 'removes just recruitment emails if you include ?recruitNotes=1', (done) ->
|
||||
loginJoe (joe) ->
|
||||
url = getURL('/auth/unsubscribe?recruitNotes=1&email='+joe.get('email'))
|
||||
request.get url, (error, response) ->
|
||||
expect(response.statusCode).toBe(200)
|
||||
user = User.findOne(joe.get('_id')).exec (err, user) ->
|
||||
expect(user.get('emails').recruitNotes.enabled).toBe(false)
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue