Fix setChannelRank
This commit is contained in:
parent
20e00af18d
commit
8be16303a1
|
@ -3021,6 +3021,10 @@ Channel.prototype.handleSetRank = function (user, data) {
|
|||
var rank = data.rank;
|
||||
|
||||
if (isNaN(rank) || rank < 1 || rank >= user.rank) {
|
||||
user.socket.emit("channelRankFail", {
|
||||
msg: "Updating user rank failed: You can't promote someone to equal or " +
|
||||
"higher rank than yourself, or demote them below rank 1."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3067,6 +3071,12 @@ Channel.prototype.handleSetRank = function (user, data) {
|
|||
}
|
||||
|
||||
self.logger.log("[mod] " + user.name + " set " + name + "'s rank to " + rank);
|
||||
|
||||
if (receiver) {
|
||||
receiver.rank = rank;
|
||||
receiver.socket.emit("rank", rank);
|
||||
}
|
||||
|
||||
self.sendAll("setUserRank", {
|
||||
name: name,
|
||||
rank: rank
|
||||
|
@ -3077,11 +3087,24 @@ Channel.prototype.handleSetRank = function (user, data) {
|
|||
|
||||
if (receiver) {
|
||||
if (Math.max(receiver.rank, receiver.global_rank) > user.rank) {
|
||||
user.socket.emit("channelRankFail", {
|
||||
msg: "Updating user rank failed: " + receiver.name + " has higher rank "+
|
||||
"than you."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (receiver.loggedIn) {
|
||||
updateDB();
|
||||
} else {
|
||||
self.logger.log("[mod] " + user.name + " set " + name + "'s rank to " + rank);
|
||||
receiver.rank = rank;
|
||||
receiver.socket.emit("rank", rank);
|
||||
|
||||
self.sendAll("setUserRank", {
|
||||
name: name,
|
||||
rank: rank
|
||||
});
|
||||
}
|
||||
} else if (self.registered) {
|
||||
updateDB();
|
||||
|
|
Loading…
Reference in a new issue