From 36051684ad2997b2189c12c28ea8f4b6fa9a05cf Mon Sep 17 00:00:00 2001
From: ric <s1094610@studenti.univpm.it>
Date: Wed, 1 Dec 2021 10:36:14 +0100
Subject: [PATCH] update

---
 backend/routes/authRoutes.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/backend/routes/authRoutes.js b/backend/routes/authRoutes.js
index 1f65400..7f26197 100644
--- a/backend/routes/authRoutes.js
+++ b/backend/routes/authRoutes.js
@@ -15,7 +15,7 @@ router.post('/signup', (req, res)=>{
         if(err){ console.log("Error with the database");};
 
         if(result!=null){
-            res.send('Username already used');
+            return res.status(422).send('Invalid username')
         }
         else{
             const user = new userFromDb({username:username, password:password});
@@ -35,7 +35,7 @@ router.post('/signin', (req, res)=>{
         if(err){ console.log("Error with the database");};
 
         if(result==null){
-            res.send('Invalid username or password');
+            return res.status(422).send('Invalid username or password');
         }
         else{
             result.comparePassword(password, function(err, isMatch) {
@@ -44,7 +44,7 @@ router.post('/signin', (req, res)=>{
                 if (isMatch){
                     res.send('Login successful');
                 }else{
-                    alert("Invalid username e/o password");
+                    return res.status(422).send('Invalid username or password');
                 }
             });
         }
-- 
GitLab