2FA client side

This commit is contained in:
2024-08-14 23:11:52 +08:00
parent ffd40f6d39
commit 920cfc4e85
3 changed files with 117 additions and 7 deletions

View File

@@ -544,10 +544,28 @@ router.post("/enable-2fa/:id", async (req, res) => {
});
});
router.post("/verify-2fa", async (req, res) => {
const { id, token } = req.body;
router.post("/has-2fa", async (req, res) => {
let email = req.body.email;
const user = await User.findOne({
where: { email: email },
});
const user = await User.findByPk(id);
if (!user) {
return res.status(404).send("User not found");
}
return res.json({
status: "success",
enabled: user.secret ? true : false,
});
});
router.post("/verify-2fa", async (req, res) => {
const { email, token } = req.body;
const user = await User.findOne({
where: { email: email },
});
if (!user) {
console.log("User not found");