This commit is contained in:
2025-04-03 17:58:09 +05:00
parent f1b6035192
commit b44c52eed6
17 changed files with 91 additions and 53 deletions
+5 -2
View File
@@ -8,13 +8,16 @@ import { createSecretKey } from "crypto";
const router = Router();
router.post("/", async (req, res) => {
const { username, password } = req.body;
const username = req.body.username.toLowerCase().trim();
const { password } = req.body;
if (!username || !password) {
return res.json({ error: "Неверный логин или пароль" });
}
const user = await User.findOne({ username }).lean();
const user = await User.findOne({
username: { $regex: new RegExp(username, "i") },
}).lean();
if (!user) {
return res.json({ error: "Неверный логин или пароль" });