diff --git a/routes/auth.js b/routes/auth.js index 9fef1b1..637bac4 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -42,7 +42,7 @@ AUTH.post('/register', async (req, res) => { delete valid[captcha] // Does the username match the requirements? - if (!(/^(?=[a-zA-Z0-9]{2,20}$).*$/.test(username))) + if (!(/^\w{2,20}$/.test(username))) return(res.send("Username does not match the requirements")) if ((await glauth.query("SELECT * FROM users WHERE name = $1::text", [ username ])).rowCount) @@ -52,8 +52,8 @@ AUTH.post('/register', async (req, res) => { hash => { const hexHash = hash2hex(hash) glauth.query( - "INSERT INTO users(name, primarygroup, passbcrypt, qam_pass) VALUES($1::text, 0, $2::text, $3::text)", - [ username, hexHash, hash ] + "INSERT INTO users(name, mail, primarygroup, passbcrypt, qam_pass) VALUES($1::text, $2::text, 0, $3::text, $4::text)", + [ username, `${username}@qwik.space`, hexHash, hash ] ).then( () => res.send("Account registered!") ).catch( @@ -156,4 +156,4 @@ AUTH.get('/captcha', async (req, res) => { }) -export default AUTH \ No newline at end of file +export default AUTH