Give up early if username is invalid for rank change
This commit is contained in:
parent
66865f718c
commit
12447ce5dc
|
@ -35,7 +35,7 @@ RankModule.prototype.sendChannelRanks = function (users) {
|
|||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
users.forEach(function (u) {
|
||||
if (u.account.effectiveRank >= 3) {
|
||||
u.socket.emit("channelRanks", ranks);
|
||||
|
@ -70,6 +70,13 @@ RankModule.prototype.handleRankChange = function (user, data) {
|
|||
var userrank = user.account.effectiveRank;
|
||||
var name = data.name.substring(0, 20).toLowerCase();
|
||||
|
||||
if (!name.match(/^[a-zA-Z0-9_-]{1,20}$/)) {
|
||||
user.socket.emit("channelRankFail", {
|
||||
msg: "Invalid target name " + data.name
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNaN(rank) || rank < 1 || (rank >= userrank && !(userrank === 4 && rank === 4))) {
|
||||
user.socket.emit("channelRankFail", {
|
||||
msg: "Updating user rank failed: You can't promote someone to a rank equal " +
|
||||
|
|
Loading…
Reference in a new issue