mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Fix /auth/unsubscribe for emails with + in them
This commit is contained in:
parent
d6586d2e94
commit
a89782b9c6
2 changed files with 18 additions and 1 deletions
|
@ -147,7 +147,16 @@ module.exports =
|
|||
res.end()
|
||||
|
||||
unsubscribe: wrap (req, res) ->
|
||||
email = req.query.email
|
||||
# need to grab email directly from url, in case it has "+" in it
|
||||
queryString = req.url.split('?')[1] or ''
|
||||
queryParts = queryString.split('&')
|
||||
email = null
|
||||
for part in queryParts
|
||||
[name, value] = part.split('=')
|
||||
if name is 'email'
|
||||
email = value
|
||||
break
|
||||
|
||||
unless email
|
||||
throw new errors.UnprocessableEntity 'No email provided to unsubscribe.'
|
||||
email = decodeURIComponent(email)
|
||||
|
|
|
@ -165,6 +165,14 @@ describe 'GET /auth/unsubscribe', ->
|
|||
expect(res.statusCode).toBe(404)
|
||||
done()
|
||||
|
||||
it 'returns 200 even if the email has a + in it', utils.wrap (done) ->
|
||||
@user.set('email', 'some+email@address.com')
|
||||
yield @user.save()
|
||||
url = getURL('/auth/unsubscribe?recruitNotes=1&email='+@user.get('email'))
|
||||
[res, body] = yield request.getAsync(url, {json: true})
|
||||
expect(res.statusCode).toBe(200)
|
||||
done()
|
||||
|
||||
describe '?recruitNotes=1', ->
|
||||
|
||||
it 'unsubscribes the user from recruitment emails', utils.wrap (done) ->
|
||||
|
|
Loading…
Reference in a new issue