+
diff --git a/webapp/src/components/login/Login.js b/webapp/src/components/login/Login.js
index 45d14d6a..08efefb2 100644
--- a/webapp/src/components/login/Login.js
+++ b/webapp/src/components/login/Login.js
@@ -17,12 +17,6 @@ const Login = () => {
const loginUser = async () => {
try {
- if(username.trim().length ===0 || password.trim().length===0)
- {
- setError("No se permite dejar espacios en blanco");
- return;
- }
-
await axios.post(`${apiEndpoint}/login`, { username, password });
// Extract data from the response
@@ -35,6 +29,15 @@ const Login = () => {
}
};
+ const checkForm = () =>
+ {
+ if(username.trim().length ===0 || password.trim().length===0)
+ {
+ setError("No se permite dejar espacios en blanco");
+ return;
+ }
+ };
+
const handleCloseSnackbar = () => {
setOpenSnackbar(false);
};
diff --git a/webapp/src/components/register/AddUser.js b/webapp/src/components/register/AddUser.js
index 9106bcae..89f315b1 100644
--- a/webapp/src/components/register/AddUser.js
+++ b/webapp/src/components/register/AddUser.js
@@ -18,19 +18,6 @@ const AddUser = () => {
const addUser = async () => {
try {
-
- if(name.trim().length === 0 || surname.trim().length === 0 || username.trim().length === 0
- || password.trim().length === 0 || passwordRepeat.trim().length === 0)
- {
- setError("No se permite dejar espacios en blanco");
- return;
- }
- if(password != passwordRepeat)
- {
- setError("Repita correctamente la contraseña que quiera usar");
- return;
- }
-
await axios.post(`${apiEndpoint}/adduser`, {
name,
surname,
@@ -45,6 +32,22 @@ const AddUser = () => {
}
};
+ const checkForm = () =>
+ {
+ if(name.trim().length === 0 || surname.trim().length === 0 || username.trim().length === 0
+ || password.trim().length === 0 || passwordRepeat.trim().length === 0)
+ {
+ setError("No se permite dejar espacios en blanco");
+ return;
+ }
+ if(password != passwordRepeat)
+ {
+ setError("Repita correctamente la contraseña que quiera usar");
+ return;
+ }
+ addUser();
+ };
+
const handleCloseSnackbar = () => {
setOpenSnackbar(false);
};
@@ -68,7 +71,7 @@ const AddUser = () => {
label="Nombre"
value={name}
onChange={(e) => setName(e.target.value)}
- id = "input"
+ id = "name"
/>
@@ -79,7 +82,7 @@ const AddUser = () => {
label="Apellidos"
value={surname}
onChange={(e) => setSurName(e.target.value)}
- id = "input"
+ id = "surname"
/>
@@ -90,7 +93,7 @@ const AddUser = () => {
label="Nombre de usuario"
value={username}
onChange={(e) => setUsername(e.target.value)}
- id = "input"
+ id = "username"
/>
@@ -103,7 +106,7 @@ const AddUser = () => {
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
- id = "input"
+ id = "password"
/>
@@ -116,12 +119,12 @@ const AddUser = () => {
type="password"
value={passwordRepeat}
onChange={(e) => setPasswordRepeat(e.target.value)}
- id = "input"
+ id = "password2"
/>