mirror of
https://github.com/xfarrow/blink
synced 2025-02-21 08:50:52 +01:00
check email already in use
This commit is contained in:
parent
46229ac247
commit
a31e6b4c66
@ -59,6 +59,16 @@ async function registerPerson(req, res){
|
|||||||
const hashPasswordPromise = bcrypt.hash(req.body.password, 10);
|
const hashPasswordPromise = bcrypt.hash(req.body.password, 10);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
// Check whether e-mail exists already (enforced by database constraints)
|
||||||
|
const existingUser = await knex('Person')
|
||||||
|
.where('email', req.body.email)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
if(existingUser){
|
||||||
|
return res.status(409).json({ error: "E-mail already in use" });
|
||||||
|
}
|
||||||
|
|
||||||
// We need to insert either both in the "Person" table
|
// We need to insert either both in the "Person" table
|
||||||
// and in the "ActivationLink" one, or in neither
|
// and in the "ActivationLink" one, or in neither
|
||||||
await knex.transaction(async (tr) => {
|
await knex.transaction(async (tr) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user