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