fix disable auth

This commit is contained in:
LouisLam 2021-08-04 01:03:40 +08:00
parent e34a8e2e4a
commit d707eba046
1 changed files with 16 additions and 7 deletions

View File

@ -114,11 +114,6 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
socket.emit("setup") socket.emit("setup")
} }
if (await setting("disableAuth")) {
console.log("Disabled Auth: auto login to admin")
await afterLogin(socket, await R.findOne("user", " username = 'admin' "))
}
socket.on("disconnect", () => { socket.on("disconnect", () => {
totalClient--; totalClient--;
}); });
@ -139,8 +134,12 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
]) ])
if (user) { if (user) {
debug("afterLogin")
await afterLogin(socket, user) await afterLogin(socket, user)
debug("afterLogin ok")
callback({ callback({
ok: true, ok: true,
}) })
@ -536,6 +535,18 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
callback(false); callback(false);
} }
}); });
debug("added all socket handlers")
debug("check auto login")
if (await setting("disableAuth")) {
console.log("Disabled Auth: auto login to admin")
await afterLogin(socket, await R.findOne("user"))
socket.emit("autoLogin")
} else {
debug("need auth")
}
}); });
console.log("Init") console.log("Init")
@ -605,8 +616,6 @@ async function afterLogin(socket, user) {
} }
sendNotificationList(socket) sendNotificationList(socket)
socket.emit("autoLogin")
} }
async function getMonitorJSONList(userID) { async function getMonitorJSONList(userID) {