generated from lucien/api-template
add: added user pages, and last messages to the home page
This commit is contained in:
parent
d7af341ca2
commit
87e7c44a5b
10 changed files with 155 additions and 31 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue