change TLDs, add blacklisting
This commit is contained in:
+17
-2
@@ -7,13 +7,19 @@ const dbConnection = database.db;
|
||||
const Sequelize = require('sequelize');
|
||||
const pageTitle = 'Domain Manager | Register New Domain';
|
||||
|
||||
const blacklistedDomains = [
|
||||
"dns.internal"
|
||||
];
|
||||
|
||||
const supportedTLDs = [
|
||||
"local",
|
||||
"internal",
|
||||
"tomato",
|
||||
"secret",
|
||||
"money",
|
||||
"lol",
|
||||
"lmao"
|
||||
"bowling",
|
||||
"lmao",
|
||||
"john"
|
||||
];
|
||||
|
||||
// Manage domains
|
||||
@@ -49,9 +55,18 @@ router.post('/domains/new', authMw.AllowIfAuthenticated, async(req, res, next) =
|
||||
const validationError = validationResult.error;
|
||||
let errors = [];
|
||||
|
||||
// Make sure domain is valid
|
||||
const domainLabel = reqBody.register_domain_label;
|
||||
const domainTLD = reqBody.register_domain_tld;
|
||||
const fullDomain = domainLabel + domainLabel;
|
||||
|
||||
if(validationError !== undefined)
|
||||
errors = validationError.details;
|
||||
|
||||
if(blacklistedDomains.includes(fullDomain.toLowerCase())) {
|
||||
errors.push('Domain is not available.');
|
||||
}
|
||||
|
||||
try {
|
||||
if(errors.length === 0) {
|
||||
const result = await dbConnection.transaction(async(t) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const Joi = require('joi');
|
||||
const domainRegistrySchema = Joi.object().keys({
|
||||
register_domain_label: Joi.string().alphanum().min(1).max(63).required(),
|
||||
register_domain_tld: Joi.string().valid("local", "tomato", "secret", "money", "lol", "lmao").required()
|
||||
register_domain_tld: Joi.string().valid("internal", "tomato", "secret", "money", "lol", "bowling", "lmao", "john").required()
|
||||
}).unknown(true);
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user