fix(verify): Don't sent post-verify email when `service` is blank.
This commit is contained in:
Родитель
e34817adcc
Коммит
06bf05a8ec
|
@ -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,
|
||||
{
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче