Skip to content

Commit

Permalink
Controles de seguridad de los formularios completados
Browse files Browse the repository at this point in the history
No se permiten elementos del formulario vacios en ambos ni que las contraseñas no coincidan al registrarse
  • Loading branch information
UO277382 committed Mar 16, 2024
1 parent 9374e72 commit 0f84ffd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions webapp/src/components/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ 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
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/components/register/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ 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,
Expand Down

0 comments on commit 0f84ffd

Please sign in to comment.