Skip to content

Commit

Permalink
fix login method
Browse files Browse the repository at this point in the history
  • Loading branch information
skotsurskiy committed Aug 20, 2024
1 parent 5d51447 commit de5e8ac
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/mate/academy/service/AuthenticationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ public class AuthenticationService {
* @return true if user by email exists and passed password is equal to user's password.
* Return false in any other cases.
*/
private UserService userService = new UserService();

public boolean login(String email, String password) {
User user = new User(email, password);
if (new UserService().findByEmail(email) != null
&& user.getPassword().equals(new UserService().findByEmail(email).getPassword())) {
return true;
}
return false;
User checkuser = userService.findByEmail(email);
return checkuser != null && user.getPassword().equals(checkuser.getPassword());
}
}

0 comments on commit de5e8ac

Please sign in to comment.