mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
38cc3394e3
Split test clean-up GitOrigin-RevId: 7dd6178487022cbefcbc85797dacc3f3fbfa17e2
33 lines
688 B
JavaScript
33 lines
688 B
JavaScript
const Settings = require('@overleaf/settings')
|
|
|
|
function requiresPrimaryEmailCheck({
|
|
email,
|
|
emails,
|
|
lastPrimaryEmailCheck,
|
|
signUpDate,
|
|
}) {
|
|
const hasExpired = date => {
|
|
if (!date) {
|
|
return true
|
|
}
|
|
return Date.now() - date.getTime() > Settings.primary_email_check_expiration
|
|
}
|
|
|
|
const primaryEmailConfirmedAt = emails.find(
|
|
emailEntry => emailEntry.email === email
|
|
).confirmedAt
|
|
|
|
if (primaryEmailConfirmedAt && !hasExpired(primaryEmailConfirmedAt)) {
|
|
return false
|
|
}
|
|
|
|
if (lastPrimaryEmailCheck) {
|
|
return hasExpired(lastPrimaryEmailCheck)
|
|
} else {
|
|
return hasExpired(signUpDate)
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
requiresPrimaryEmailCheck,
|
|
}
|