From f333094079740f97338c7ff29f95c8fbcc4af9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fern=C3=A1ndez=20Noriega?= Date: Sun, 7 Apr 2024 22:30:32 +0200 Subject: [PATCH 1/2] Solved problem where the registration showed an error when the user was been correctly added --- users/userservice/user-service.js | 2 +- webapp/src/components/AddUser.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index e4dcff6..94dc744 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -119,7 +119,7 @@ app.post('/adduser', async (req, res) => { }); await newUser.save(); - res.json(newUser); + res.status(200).json({response: "User added correctly"}); } catch (error) { res.status(400).json({ error: error.message }); }}); diff --git a/webapp/src/components/AddUser.jsx b/webapp/src/components/AddUser.jsx index b677964..1e7225c 100644 --- a/webapp/src/components/AddUser.jsx +++ b/webapp/src/components/AddUser.jsx @@ -13,7 +13,7 @@ const AddUser = () => { const [cpassword, setcPassword] = useState(''); const [error, setError] = useState(''); const [openSnackbar, setOpenSnackbar] = useState(false); - const { navigate } = useNavigate(); + const navigate = useNavigate(); const addUser = async () => { try { From 83ba07da60a0bf31d4253fde17a32a125a63680a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fern=C3=A1ndez=20Noriega?= Date: Sun, 7 Apr 2024 22:40:06 +0200 Subject: [PATCH 2/2] User is returned in the response again in the '/adduser' (Thought unncessary but needed as checked in tests) --- users/userservice/user-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 94dc744..0a53704 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -119,7 +119,7 @@ app.post('/adduser', async (req, res) => { }); await newUser.save(); - res.status(200).json({response: "User added correctly"}); + res.status(200).json(newUser); } catch (error) { res.status(400).json({ error: error.message }); }});