From 1242f6e35a989148fc331ae5a332a7ae556f1ab5 Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Wed, 1 Sep 2021 04:00:17 +0000 Subject: [PATCH] Verbose --- server.js | 9 +++++++++ server_test.js | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index deacf74..1612e17 100644 --- a/server.js +++ b/server.js @@ -831,6 +831,12 @@ app.post(PREFIX+"/registerUser",(req,res)=>{ db.query('insert into users(username,email,password_hash,created_on,roles_id,avatar,recovery_hash) values($1,$2,$3,$4,(select id from roles where name=\'Guest\'),$5,$6)',[req.body.username,req.body.email,req.body.password,new Date(),req.body.avatar,req.body.userID]) } }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } else { + res.status(500).send("Unsupported operation!") } }) @@ -846,6 +852,9 @@ app.post(PREFIX+"/validUser",(req,res)=>{ res.status(200).json({verified:false}) } }) + .catch((err)=>{ + res.status(500).send(err.message) + }) } else { db.query('select * from users where username=$1 and password_hash=$2 limit 1',[req.body.username,sh.SecretHash(req.body.password)]) .then((data)=>{ diff --git a/server_test.js b/server_test.js index 4b81cf9..c408039 100644 --- a/server_test.js +++ b/server_test.js @@ -785,6 +785,12 @@ app.post(PREFIX+"/registerUser",(req,res)=>{ db.query('insert into users(username,email,password_hash,created_on,roles_id,avatar,recovery_hash) values($1,$2,$3,$4,(select id from roles where name=\'Guest\'),$5,$6)',[req.body.username,req.body.email,req.body.password,new Date(),req.body.avatar,req.body.userID]) } }) + .catch((err)=>{ + console.log(err.message) + res.status(500).send(err.message) + }) + } else { + res.status(500).send("Unsupported operation!") } }) @@ -797,10 +803,12 @@ app.post(PREFIX+"/validUser",(req,res)=>{ if (data.rows.length>0) { res.status(200).json({verified:true}) } else { - //This doesn't exist. At this time we will register them since this is external. - db.query('insert into users(username,email,password_hash,created_on,roles_id,avatar,recovery_hash) values($1,$2,$3,$4,(select id from roles where name=\'Guest\'),$5,$6)',[req.body.username,req.body.email,req.body.password,new Date(),req.body.avatar,req.body.userID]) + res.status(200).json({verified:false}) } }) + .catch((err)=>{ + res.status(500).send(err.message) + }) } else { db.query('select * from users where username=$1 and password_hash=$2 limit 1',[req.body.username,sh.SecretHash(req.body.password)]) .then((data)=>{