diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index be958427..7a49e593 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -19,6 +19,7 @@ mongoose.connect(mongoUri); // Function to validate required fields in the request body function validateRequiredFields(req, requiredFields) { + //TODO: Add more validations for (const field of requiredFields) { if (!(field in req.body)) { throw new Error(`Missing required field: ${field}`); @@ -40,7 +41,7 @@ app.post('/adduser', async (req, res) => { }); await newUser.save(); - res.json(newUser); + res.json({username: newUser.username}); } catch (error) { res.status(400).json({ error: error.message }); }}); diff --git a/webapp/src/components/loginAndRegistration/AddUser.js b/webapp/src/components/loginAndRegistration/AddUser.js index 5911c7f5..c7158150 100644 --- a/webapp/src/components/loginAndRegistration/AddUser.js +++ b/webapp/src/components/loginAndRegistration/AddUser.js @@ -1,35 +1,72 @@ import React from "react"; -import { FaUser, FaLock } from "react-icons/fa"; import "../../custom.css"; import { Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; +import axios from 'axios'; +import { useState } from 'react'; const AddUser = () => { + const apiUrl = (process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000') + "/adduser"; const { t } = useTranslation("global"); + const [username, setUsername] = useState(''); + const [password, setPassword] = useState(''); + const [repeatPassword, setRepeatPassword] = useState(''); - return ( -