diff --git a/lib/routes/account.js b/lib/routes/account.js index 4c329ed1..2ea3f459 100644 --- a/lib/routes/account.js +++ b/lib/routes/account.js @@ -1218,10 +1218,8 @@ module.exports = function ( }) .then(function () { // Our post-verification email is very specific to sync, - // so don't send it if we're sure this is not for sync. - // Older clients will not send a 'service' param here - // so we can't always be sure. - if (! service || service === 'sync') { + // so only send it if we're sure this is for sync. + if (service === 'sync') { return mailer.sendPostVerifyEmail( account.email, { diff --git a/test/client/index.js b/test/client/index.js index 439fac01..10a4d1b4 100644 --- a/test/client/index.js +++ b/test/client/index.js @@ -100,8 +100,10 @@ Client.createAndVerify = function (origin, email, password, mailbox, options) { ) .then( function () { - // clear the post verified email - return mailbox.waitForEmail(email) + // clear the post verified email, if one was sent + if (options && options.service === 'sync') { + return mailbox.waitForEmail(email) + } } ) .then( diff --git a/test/remote/account_create_tests.js b/test/remote/account_create_tests.js index 0b289a39..be3498e2 100644 --- a/test/remote/account_create_tests.js +++ b/test/remote/account_create_tests.js @@ -71,7 +71,7 @@ TestServer.start(config) ) .then( function (verifyCode) { - return client.verifyEmail(verifyCode) + return client.verifyEmail(verifyCode, { service: 'sync' }) } ) .then( @@ -570,6 +570,60 @@ TestServer.start(config) } ) + test( + 'create account for unspecified service does not get post-verify email', + function (t) { + var email = server.uniqueEmail() + var password = 'allyourbasearebelongtous' + var client = null + return Client.create(config.publicUrl, email, password) + .then( + function (x) { + client = x + t.ok('account was created') + } + ) + .then( + function () { + return server.mailbox.waitForCode(email) + } + ) + .then( + function (verifyCode) { + return client.verifyEmail(verifyCode, { }) // no 'service' param + } + ) + .then( + function () { + return client.emailStatus() + } + ) + .then( + function (status) { + t.equal(status.verified, true) + } + ) + .then( + function () { + // It's hard to test for "an email didn't arrive. + // Instead trigger sending of another email and test + // that there wasn't anything in the queue before it. + return client.forgotPassword() + } + ) + .then( + function () { + return server.mailbox.waitForCode(email) + } + ) + .then( + function (code) { + t.ok(code, 'the next email was reset-password, not post-verify') + } + ) + } + ) + test( 'teardown', function (t) {