(node:20955) UnhandledPromiseRejectionWarning: Error: Callback function is not available with promise clients.
at PromisePool.query (/home/nikita/Загрузки/galaxy-of-hearing/node_modules/mysql2/promise.js:343:13)
at /home/nikita/Загрузки/galaxy-of-hearing/index.js:70:42
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:20955) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20955) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:20955) UnhandledPromiseRejectionWarning: Error: Callback function is not available with promise clients.
at PromisePool.query (/home/nikita/Загрузки/galaxy-of-hearing/node_modules/mysql2/promise.js:343:13)
at /home/nikita/Загрузки/galaxy-of-hearing/index.js:70:42
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:20955) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
app.post("/registration", urlencodedParser, async(req, res) => {
if (!req.body) {
res.send("Вы не заполнили форму.");
}
const [row] = await dbConnection.execute( // Здесь мы запрашиваем данные, существует ли введенный пользователем логин или нет.
"SELECT * FROM `users` WHERE `name`=?", [req.body.userName]
);
if (req.body.password == 123456 || req.body.password == 098765 || req.body.password == 987654 || req.body.password == 111111 || req.body.password == 222222 || req.body.password == 333333 || req.body.password == 444444 || req.body.password == 555555 || req.body.password == 666666 || req.body.password == 777777 || req.body.password == 888888 || req.body.password == 999999 || req.body.password == 000000 || req.body.password == 123123) {
res.send("Ваш пароль слишком простой, вам нужно придумать посложнее.");
} // Checking password. If password is easy, server send error.
else {
if (row.length === 0) { // Checking users, if username already registered, server will send error.
if (req.body.password.length >= 6) { // Checking length password. If less than 6 - server will send error.
let post = {
name: `${req.body.userName}`,
password: `${req.body.password}`
} // Структура данных для сервера
let sql = "INSERT INTO users SET ?" // Writing data to the DB
let query = dbConnection.query(sql, post => {});
res.send(`Вы зарегистрированы!`);
} else {
res.send('Пароль должен быть минимум из 6 символов')
}
} else {
res.send("Имя пользователя уже существует, попробуйте другое имя.");
}
}
});