add: added user pages, and last messages to the home page

This commit is contained in:
Lukian 2025-03-25 16:47:30 +01:00
parent d7af341ca2
commit 87e7c44a5b
10 changed files with 155 additions and 31 deletions

View file

@ -31,6 +31,11 @@ router.post('/register', async (req, res) => {
return res.status(401).send({ error: 'Username already exists' });
}
if (!/^[a-zA-Z0-9-_]+$/.test(username)) {
connection.end();
return res.status(400).send({ error: 'Invalid username' });
}
const hash = sha256(password);
await addUser(connection, username, hash);
connection.end();