Skip to content

Commit

Permalink
fix: removed disposable lookup due to false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed May 8, 2024
1 parent 7750ad2 commit cb0064f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
12 changes: 7 additions & 5 deletions app/models/domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const REGEX_MAIL_DISPOSABLE_INBOX = new RE2(
//
// TODO: this should be moved to redis or its own package under forwardemail or @ladjs
//
/*
const disposableDomains = new Set();
async function crawlDisposable() {
Expand All @@ -110,6 +111,7 @@ async function crawlDisposable() {
logger.error(err);
}
}
*/

const REGEX_VERIFICATION = new RE2(/[^\da-z]/i);

Expand Down Expand Up @@ -1691,9 +1693,9 @@ function getNameRestrictions(domainName) {
const isGood = config.goodDomains.some((ext) =>
rootDomain.endsWith(`.${ext}`)
);
const isDisposable =
REGEX_MAIL_DISPOSABLE_INBOX.test(rootDomain) ||
disposableDomains.has(rootDomain);
const isDisposable = REGEX_MAIL_DISPOSABLE_INBOX.test(rootDomain);
// REGEX_MAIL_DISPOSABLE_INBOX.test(rootDomain) ||
// disposableDomains.has(rootDomain);
// NOTE: this also takes into account `nic.ext` for registrars
const isRestricted = config.restrictedDomains.some(
(ext) =>
Expand Down Expand Up @@ -2225,5 +2227,5 @@ Domains.statics.getStorageUsed = getStorageUsed;

module.exports = conn.model('Domains', Domains);

setInterval(crawlDisposable, ms('1d'));
crawlDisposable();
// setInterval(crawlDisposable, ms('1d'));
// crawlDisposable();
44 changes: 23 additions & 21 deletions app/models/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,28 +674,28 @@ Users.virtual(config.userFields.verificationPinHasExpired).get(function () {
//
// TODO: this should be moved to redis or its own package under forwardemail or @ladjs
//
const disposableDomains = new Set();
async function crawlDisposable() {
try {
const response = await retryRequest(
'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'
);

const json = await response.body.json();
if (!Array.isArray(json) || json.length === 0) {
throw new Error('Disposable did not crawl data.');
}

for (const d of json) {
disposableDomains.add(d);
}
} catch (err) {
logger.error(err);
}
}
// const disposableDomains = new Set();
// async function crawlDisposable() {
// try {
// const response = await retryRequest(
// 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'
// );
//
// const json = await response.body.json();
// if (!Array.isArray(json) || json.length === 0) {
// throw new Error('Disposable did not crawl data.');
// }
//
// for (const d of json) {
// disposableDomains.add(d);
// }
// } catch (err) {
// logger.error(err);
// }
// }

setInterval(crawlDisposable, ms('1d'));
crawlDisposable();
// setInterval(crawlDisposable, ms('1d'));
// crawlDisposable();

// This ensures that `email` was already validated, trimmed, lowercased
Users.pre('save', async function (next) {
Expand All @@ -705,6 +705,7 @@ Users.pre('save', async function (next) {
return next();
}

/*
const domain = this.email.split('@')[1];
if (disposableDomains.size === 0) {
await crawlDisposable();
Expand All @@ -720,6 +721,7 @@ Users.pre('save', async function (next) {
error.no_translate = true;
return next(error);
}
*/

// TODO: prevent user from signing up with one of our global vanity names
next();
Expand Down

0 comments on commit cb0064f

Please sign in to comment.