reject logins before user connects to node

This commit is contained in:
Elijah R
2024-04-07 15:15:20 -04:00
committed by Elijah R
parent 0821ac89e8
commit 0c3d482e82

View File

@@ -249,6 +249,10 @@ export default class WSServer {
switch (msgArr[0]) { switch (msgArr[0]) {
case "login": case "login":
if (msgArr.length !== 2 || !this.Config.auth.enabled) return; if (msgArr.length !== 2 || !this.Config.auth.enabled) return;
if (!client.connectedToNode) {
client.sendMsg(guacutils.encode("login", "0", "You must connect to the VM before logging in."));
return;
}
var res = await this.auth!.Authenticate(msgArr[1], client); var res = await this.auth!.Authenticate(msgArr[1], client);
if (res.clientSuccess) { if (res.clientSuccess) {
log("INFO", `${client.IP.address} logged in as ${res.username}`); log("INFO", `${client.IP.address} logged in as ${res.username}`);