add remove-2fa command

This commit is contained in:
Louis Lam
2021-11-18 18:22:03 +08:00
parent 74d2b38cb6
commit 5d3bf68123
4 changed files with 77 additions and 4 deletions

14
server/2fa.js Normal file
View File

@@ -0,0 +1,14 @@
const { checkLogin } = require("./util-server");
const { R } = require("redbean-node");
class TwoFA {
static async disable2FA(userID) {
return await R.exec("UPDATE `user` SET twofa_status = 0 WHERE id = ? ", [
userID,
]);
}
}
module.exports = TwoFA;

View File

@@ -120,6 +120,7 @@ module.exports.io = io;
const { sendNotificationList, sendHeartbeatList, sendImportantHeartbeatList, sendInfo } = require("./client");
const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler");
const databaseSocketHandler = require("./socket-handlers/database-socket-handler");
const TwoFA = require("./2fa");
app.use(express.json());
@@ -420,10 +421,7 @@ exports.entryPage = "dashboard";
socket.on("disable2FA", async (callback) => {
try {
checkLogin(socket);
await R.exec("UPDATE `user` SET twofa_status = 0 WHERE id = ? ", [
socket.userID,
]);
await TwoFA.disable2FA(socket.userID);
callback({
ok: true,