diff --git a/config.example.toml b/config.example.toml index c37c86d..78ab4d1 100644 --- a/config.example.toml +++ b/config.example.toml @@ -21,6 +21,8 @@ secretKey = "hunter2" [auth.guestPermissions] chat = true turn = false +callForReset = false +vote = true [vm] qemuArgs = "qemu-system-x86_64" diff --git a/src/WSServer.ts b/src/WSServer.ts index dde946a..6155b00 100644 --- a/src/WSServer.ts +++ b/src/WSServer.ts @@ -452,6 +452,10 @@ export default class WSServer { switch (msgArr[1]) { case "1": if (!this.voteInProgress) { + if (this.Config.auth.enabled && client.rank === Rank.Unregistered && !this.Config.auth.guestPermissions.callForReset) { + client.sendMsg(guacutils.encode("chat", "", "You need to login to do that.")); + return; + } if (this.voteCooldown !== 0) { client.sendMsg(guacutils.encode("vote", "3", this.voteCooldown.toString())); return; @@ -459,12 +463,20 @@ export default class WSServer { this.startVote(); this.clients.forEach(c => c.sendMsg(guacutils.encode("chat", "", `${client.username} has started a vote to reset the VM.`))); } + if (this.Config.auth.enabled && client.rank === Rank.Unregistered && !this.Config.auth.guestPermissions.vote) { + client.sendMsg(guacutils.encode("chat", "", "You need to login to do that.")); + return; + } else if (client.IP.vote !== true) this.clients.forEach(c => c.sendMsg(guacutils.encode("chat", "", `${client.username} has voted yes.`))); client.IP.vote = true; break; case "0": if (!this.voteInProgress) return; + if (this.Config.auth.enabled && client.rank === Rank.Unregistered && !this.Config.auth.guestPermissions.vote) { + client.sendMsg(guacutils.encode("chat", "", "You need to login to do that.")); + return; + } if (client.IP.vote !== false) this.clients.forEach(c => c.sendMsg(guacutils.encode("chat", "", `${client.username} has voted no.`))); client.IP.vote = false;