Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(config): Add config for unverified account to exist before second…
Browse files Browse the repository at this point in the history
…ary email can be create with the same email (#1845) r=vladikoff
  • Loading branch information
vbudhram authored and vladikoff committed Apr 20, 2017
1 parent 3d80e82 commit d0b5976
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
"ipProfiling": {
"allowedRecency": 0
}
},
"secondaryEmail": {
"enabled": true
}
}
6 changes: 6 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,12 @@ var conf = convict({
default: false,
format: Boolean,
env: 'SECONDARY_EMAIL_ENABLED'
},
minUnverifiedAccountTime: {
doc: 'The minimum amount of time an account can be unverified before another account can use it for secondary email',
default: '1 day',
format: 'duration',
env: 'SECONDARY_EMAIL_MIN_UNVERIFIED_ACCOUNT_TIME'
}
}
})
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -2092,8 +2092,9 @@ module.exports = (
// a day, if so, delete account so another user can add it as a
// secondary email
const msSinceCreated = Date.now() - emailRecord.createdAt
if (msSinceCreated >= MS_ONE_DAY) {
return db.deleteAccount(emailRecord.uid)
const minUnverifiedAccountTime = config.secondaryEmail.minUnverifiedAccountTime
if (msSinceCreated >= minUnverifiedAccountTime) {
return db.deleteAccount(emailRecord)
} else {
throw error.unverifiedPrimaryEmailNewlyCreated()
}
Expand Down
3 changes: 2 additions & 1 deletion test/local/routes/recovery_email.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ describe('/recovery_email', () => {
},
config: {
secondaryEmail: {
enabled: true
enabled: true,
minUnverifiedAccountTime: MS_IN_DAY
}
},
customs: mockCustoms,
Expand Down

0 comments on commit d0b5976

Please sign in to comment.