mirror of https://github.com/calzoneman/sync.git
Reject guest names matching the reserved usernames regex
This commit is contained in:
parent
90b5e5e09f
commit
3413c3bdaa
13
src/user.js
13
src/user.js
|
@ -381,6 +381,19 @@ User.prototype.guestLogin = function (name) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (name.match(Config.get("reserved-names.usernames"))) {
|
||||
LOGGER.warn(
|
||||
'Rejecting attempt by %s to use reserved username "%s"',
|
||||
self.realip,
|
||||
name
|
||||
);
|
||||
self.socket.emit("login", {
|
||||
success: false,
|
||||
error: "That username is reserved."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent duplicate logins
|
||||
self.setFlag(Flags.U_LOGGING_IN);
|
||||
db.users.isUsernameTaken(name, function (err, taken) {
|
||||
|
|
|
@ -190,6 +190,11 @@ function handleRegister(req, res) {
|
|||
}
|
||||
|
||||
if (name.match(Config.get("reserved-names.usernames"))) {
|
||||
LOGGER.warn(
|
||||
'Rejecting attempt by %s to register reserved username "%s"',
|
||||
ip,
|
||||
name
|
||||
);
|
||||
sendPug(res, "register", {
|
||||
registerError: "That username is reserved"
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue