Skip to content

Commit

Permalink
Not tested, hope it works
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubZojdzik committed Apr 17, 2024
1 parent cd62e4f commit dde32e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/controllers/users.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const register = async (request, response) => {
return response.status(401).send('Konto o danym mailu lub nazwie już istnieje!');
}

const unverified = await pool.query('SELECT id FROM users WHERE verified = false AND email = $1', [email]);
if (unverified.rowCount)
{
pool.query('DELETE FROM users WHERE id = $1', [unverified.rows[0].id])
}

const salt = await bcrypt.genSalt(10);
const hash = await bcrypt.hash(password, salt);
await pool.query('INSERT INTO users (name, email, password) VALUES ($1, $2, $3)', [name, email, hash]);
Expand Down

0 comments on commit dde32e4

Please sign in to comment.