upd
This commit is contained in:
@@ -6,6 +6,8 @@ const userSchema = new Schema(
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
trim: true,
|
||||
lowercase: true,
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
|
||||
@@ -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: "Неверный логин или пароль" });
|
||||
|
||||
Reference in New Issue
Block a user