mirror of https://github.com/calzoneman/sync.git
Add config keys for reserved names
This commit is contained in:
parent
0998e89f5d
commit
767e90a757
|
@ -76,3 +76,19 @@ aliases:
|
|||
|
||||
# Workaround for Vimeo blocking my domain
|
||||
vimeo-workaround: false
|
||||
|
||||
# Regular expressions for defining reserved user and channel names and page titles
|
||||
# The list of regular expressions will be joined with an OR, and compared without
|
||||
# case sensitivity.
|
||||
#
|
||||
# Default: reserve any name containing "admin[istrator]" or "owner" as a word
|
||||
# but only if it is separated by a dash or underscore (e.g. dadmin is not reserved
|
||||
# but d-admin is)
|
||||
reserved-names:
|
||||
usernames:
|
||||
- '^(.*?[-_])?admin(istrator)?([-_].*)?$'
|
||||
- '^(.*?[-_])?owner([-_].*)?$'
|
||||
channels:
|
||||
- '^(.*?[-_])?admin(istrator)?([-_].*)?$'
|
||||
- '^(.*?[-_])?owner([-_].*)?$'
|
||||
pagetitles: []
|
||||
|
|
|
@ -10,6 +10,7 @@ var InfoGetter = require("./get-info");
|
|||
var ChatCommand = require("./chatcommand");
|
||||
var XSS = require("./xss");
|
||||
var Media = require("./media").Media;
|
||||
var Config = require("./config");
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
@ -2451,7 +2452,15 @@ Channel.prototype.handleUpdateOptions = function (user, data) {
|
|||
}
|
||||
|
||||
if ("pagetitle" in data && user.rank >= 3) {
|
||||
this.opts.pagetitle = (""+data.pagetitle).substring(0, 100);
|
||||
var title = (""+data.pagetitle).substring(0, 100);
|
||||
if (!title.trim().match(Config.get("reserved-names.pagetitles"))) {
|
||||
this.opts.pagetitle = (""+data.pagetitle).substring(0, 100);
|
||||
} else {
|
||||
user.socket.emit("errorMsg", {
|
||||
msg: "That pagetitle is reserved",
|
||||
alert: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if ("maxlength" in data) {
|
||||
|
|
|
@ -60,8 +60,12 @@ var defaults = {
|
|||
"max-age": 2592000000
|
||||
},
|
||||
"html-template": {
|
||||
title: "CyTube Beta",
|
||||
description: "Free, open source synchtube"
|
||||
title: "CyTube Beta", description: "Free, open source synchtube"
|
||||
},
|
||||
"reserved-names": {
|
||||
usernames: ["^(.*?[-_])?admin(istrator)?([-_].*)?$", "^(.*?[-_])?owner([-_].*)?$"],
|
||||
channels: ["^(.*?[-_])?admin(istrator)?([-_].*)?$", "^(.*?[-_])?owner([-_].*)?$"],
|
||||
pagetitles: []
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -134,6 +138,15 @@ exports.load = function (file) {
|
|||
|
||||
cfg.http.domain = cfg.http.domain.replace(/\/*$/, "");
|
||||
cfg.https.domain = cfg.https.domain.replace(/\/*$/, "");
|
||||
|
||||
var reserved = cfg["reserved-names"];
|
||||
for (var key in reserved) {
|
||||
if (reserved[key] && reserved[key].length > 0) {
|
||||
reserved[key] = new RegExp(reserved[key].join("|"), "i");
|
||||
} else {
|
||||
reserved[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.syslog.log("Loaded configuration from " + file);
|
||||
};
|
||||
|
|
|
@ -251,6 +251,18 @@ function handleNewChannel(req, res) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (name.match(Config.get("reserved-names.channels"))) {
|
||||
db.channels.listUserChannels(loginName, function (err2, channels) {
|
||||
sendJade(res, "account-channels", {
|
||||
loggedIn: true,
|
||||
loginName: loginName,
|
||||
channels: err2 ? [] : channels,
|
||||
newChannelError: "That channel name is reserved"
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
db.channels.register(name, user.name, function (err, channel) {
|
||||
if (!err) {
|
||||
Logger.eventlog.log("[channel] " + user.name + "@" +
|
||||
|
|
|
@ -12,6 +12,7 @@ var sendJade = require("./jade").sendJade;
|
|||
var Logger = require("../logger");
|
||||
var $util = require("../utilities");
|
||||
var db = require("../database");
|
||||
var Config = require("../config");
|
||||
|
||||
/**
|
||||
* Processes a login request. Sets a cookie upon successful authentication
|
||||
|
@ -168,6 +169,13 @@ function handleRegister(req, res) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (name.match(Config.get("reserved-names.usernames"))) {
|
||||
sendJade(res, "register", {
|
||||
registerError: "That username is reserved"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length === 0) {
|
||||
sendJade(res, "register", {
|
||||
registerError: "Password must not be empty"
|
||||
|
|
|
@ -49,7 +49,11 @@ Callbacks = {
|
|||
},
|
||||
|
||||
errorMsg: function(data) {
|
||||
errDialog(data.msg);
|
||||
if (data.alert) {
|
||||
alert(data.msg);
|
||||
} else {
|
||||
errDialog(data.msg);
|
||||
}
|
||||
},
|
||||
|
||||
costanza: function (data) {
|
||||
|
|
Loading…
Reference in New Issue