Docker
This commit is contained in:
@@ -46,22 +46,26 @@ router.post('/register', registerLimiter, async (req, res) => {
|
||||
}
|
||||
|
||||
if (!username || !password) {
|
||||
console.log('Registration failed: missing username or password');
|
||||
res.status(400).json({ error: 'Username и пароль обязательны' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z0-9_]{3,20}$/.test(username)) {
|
||||
console.log('Registration failed: invalid username format', username);
|
||||
res.status(400).json({ error: 'Username: 3-20 символов, только латиница, цифры, _' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length < config.minPasswordLength) {
|
||||
console.log('Registration failed: password too short');
|
||||
res.status(400).json({ error: `Пароль должен быть не менее ${config.minPasswordLength} символов` });
|
||||
return;
|
||||
}
|
||||
|
||||
// Password must contain at least one letter and one digit
|
||||
if (!/[a-zA-Zа-яА-Я]/.test(password) || !/\d/.test(password)) {
|
||||
console.log('Registration failed: password missing letters or digits');
|
||||
res.status(400).json({ error: 'Пароль должен содержать буквы и цифры' });
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user