Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Refactoring login function
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenFern committed Feb 6, 2024
1 parent a830f6f commit 3280c9d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions webapp/src/components/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ const Login = () =>
{
e.preventDefault();

if ( username.trim() === '' || password.trim() === '' )
if ( username.trim() !== '' && password.trim() !== '' )
{
if ( username.trim() === '' )
setValidUsername(false);

if ( password.trim() === '' )
setValidPassword(false);
setValidUsername(true);
setValidPassword(true);

await login(username, password);
return;
}

await login(username, password);
if ( username.trim() === '' )
setValidUsername(false);

if ( password.trim() === '' )
setValidPassword(false);
}

const checkUsername = (e) =>
Expand Down

0 comments on commit 3280c9d

Please sign in to comment.